【发布时间】:2019-07-11 07:29:57
【问题描述】:
我正在尝试在我的 react 应用程序的特定页面上隐藏/禁用“标题”,下面给出的是我的组件的代码:
我想在“/dct”路径上隐藏标题
export default function (WrappedComponent,theme) {
class Authentication extends PureComponent {
constructor(props) {
super(props);
this.state = { };
}
componentDidUpdate() {
this.checkAuth();
}
checkAuth() {
const { isLoggedIn, history: { push} } = this.props;
if (!isLoggedIn) {
push('/')
}
}
render() {
return (
<Fragment>
<article data-theme={theme}>
{this.checkAuth()}
<Header />
<main>
{this.props.isLoggedIn && <WrappedComponent />}
</main>
<Footer />
</article>
</Fragment>
);
}
}
const mapStateToProps = (state) => {
return {
isLoggedIn: state.login.loggedIn
}
}
return connect(mapStateToProps)(Authentication);
}
提前致谢
【问题讨论】:
标签: reactjs redux react-redux