const AuthRoute = ({ component: Component, render, isSignedIn, ...rest }) => (
<Route {...rest} render={props => {
if (!isSignedIn) return (
<Redirect to={{
pathname: "/signin",
state: { referrer: props.history.location.pathname }
}} />
);
if (render) return render({ ...props });
return <Component {...props} />;
}} />
);
const mapStateToProps = state => ({
isSignedIn: isSignedInSelector(state),
});
export default connect(mapStateToProps)(AuthRoute);
<AuthRoute path="/admin" component={Admin} />
<Switch>
{isSignedIn && <Route path="/admin" component={Admin} />}
<Route path="/partner/:name" component={Partner}/>
<Route component={() => <div>page not found</div>} />
</Switch>
createItem(task) {
this.setState(prevState => ({
tasks: [
...prevState.tasks,
{ name: task, status: false },
],
}));
}
static getDerivedStateFromProps(props, state) {
if (props.data !== state.data) {
return {
data: props.data,
};
}
return null;
}
render() {
return(
<Wrapper>
<Header />
<Main />
<Footer />
</Wrapper>
);
}
const MainPageLayout = ({ children }) => (
<Wrapper>
<Header />
<PageContent>
{children}
</PageContent>
<Footer />
</Wrapper>
);
const SomePage = () => (
<MainPageLayout>
{/* page code */}
</MainPageLayout>
);
<Provider>
<Router>
<App />
</Router>
</Provider>
if (posts && posts == 'undefained') {
let posts = this.props
const { data } = this.props;