Answer the question
In order to leave comments, you need to log in
What is the best way to hide divs on a specific page in React?
There is a react without any whistles, only react-router
And as planned, the main page and 404 page differ from the others in the template:
404 does not have a header and footer, on the main page there should not be a logo in the
header Component (HOC) like this:
// Это основное приложение с роутером и HOC
function i(Page){
return class HF extends React.Component{
render(){
return (
<Content><Page /></Content>
);
}
};
}
class App extends Component {
render() {
return (
<BrowserRouter>
<div>
<Switch>
<Route exact path={'/'} component={i(Home)} />
<Route exact path={'/contacts'} component={i(Contact)} />
<Route component={Error} />
</Switch>
</div>
</BrowserRouter>
);
}
}
export class Content extends React.Component{
render(){
return(
<div>
<div className="head_panel">
<div className="logotype">
<img src={logo}></img>
</div>
<Nav />
</div>
<div className="main-page">
{this.props.children}
</div>
<div className="footer">
</div>
</div>
)
}
}
Answer the question
In order to leave comments, you need to log in
In the case of HOC something like this:
I would use a component in the page code instead of HOC:
render() {
return(
<PageLayout shouldShowLogo={false}>
{/* код страницы */}
</PageLayout>
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question