0
I am developing a login/registration page in React, however, I came across the following problem:
<div className="auth-container">
<BrowserRouter>
<Hint />
<Switch>
<Route exact path="/" component={LoginAside}/>
<Route path="/register" component={RegisterAside}/>
<Route path="/create-password" component={CreatePassword}/>
</Switch>
</BrowserRouter>
</div>
The Hint component (yellow screen) should appear during all transitions of the login/registration screen, repeating only the form components that are on the right side. It happens that the moment the user logs in, I want to be redirected to a new screen of the application, however, this screen should not repeat the Hint component. You could help me to accomplish this. I thank you!
Hint code:
import React from 'react';
import Slider from "react-slick";
import flatAvaliation from '../../assets/images/flat-avaliation.svg';
import flatSecurity from '../../assets/images/flat-security.svg';
import flatAnonymous from '../../assets/images/flat-anonymous.svg';
import '../../../node_modules/slick-carousel/slick/slick.css';
import '../../../node_modules/slick-carousel/slick/slick-theme.css';
import './styles.css'
export default function Hint() {
const settings = {
autoplay: true,
autoplaySpeed: 10000,
dots: true,
infinite: true,
speed: 1000,
slidesToShow: 1,
slidesToScroll: 1
};
return(
<div className="hints-container">
<Slider style={{width: '80%'}} {...settings}>
<div className="hint-item">
<img
className="hint-img"
src={flatAvaliation}
/>
<h1 className="hint-title">Seu site de avaliação!</h1>
<p className="hint-description">
Laboris duis est aliqua id est do consectetur et do cillum Lorem commodo. Occaecat laboris consectetur commodo enim irure culpa veniam cillum ut cupidatat in ipsum eiusmod. In mollit veniam excepteur sunt aute in. Amet eu amet reprehenderit est officia ipsum sunt amet aliquip occaecat sunt. Velit nulla non officia velit fugiat do qui exercitation enim.
</p>
</div>
<div className="hint-item">
<img
className="hint-img"
src={flatSecurity}
/>
<h1 className="hint-title">Segurança</h1>
<p className="hint-description">
Laboris duis est aliqua id est do consectetur et do cillum Lorem commodo. Occaecat laboris consectetur commodo enim irure culpa veniam cillum ut cupidatat in ipsum eiusmod. In mollit veniam excepteur sunt aute in. Amet eu amet reprehenderit est officia ipsum sunt amet aliquip occaecat sunt. Velit nulla non officia velit fugiat do qui exercitation enim.
</p>
</div>
<div className="hint-item">
<img
className="hint-img"
src={flatAnonymous}
/>
<h1 className="hint-title">Anonimato</h1>
<p className="hint-description">
Laboris duis est aliqua id est do consectetur et do cillum Lorem commodo. Occaecat laboris consectetur commodo enim irure culpa veniam cillum ut cupidatat in ipsum eiusmod. In mollit veniam excepteur sunt aute in. Amet eu amet reprehenderit est officia ipsum sunt amet aliquip occaecat sunt. Velit nulla non officia velit fugiat do qui exercitation enim.
</p>
</div>
</Slider>
</div>
);
}
Tried to put the yellow component only on login screen and logs ?
– Brandon Marcos
But then it wouldn’t be redundant?
– André Luiz
You might think the following, the component it serves to be reused, example, I have a code that creates a modal that repeats several times in my application, so I create a component with the modal code and use my modal component everywhere in my application, would be more or less what you are doing, created a yellow component and called it where it was needed.
– Brandon Marcos
Now it’s clearer. Just one more question. If I am on the login page and decide to go to the registration page, will the yellow component render again or just the registration form? Basically I want to know if the browser will make a new request for the yellow component.
– André Luiz
Can post yellow component code ?
– Brandon Marcos
I edited the content of the main publication
– André Luiz
Do a test by placing the component on separate screens, see what happens and let us know if it worked.
– Brandon Marcos
Just put the hint component on the login screen and if you have more of the hint component, just put it on. Although only with this component is it difficult to say anything else
– novic