(, , ).
HOC:
export const withAuth = connectedReduxRedirect({
redirectPath: '/login',
authenticatedSelector: state => state.user.isAuthenticated,
authenticatingSelector: state => state.user.loading,
wrapperDisplayName: 'UserIsAuthenticated'
});
HOC:
export const withFlow = (step) = connectedReduxRedirect({
redirectPath: '/initial-flow-step',
authenticatedSelector: state => state.flow[step] === true,
wrapperDisplayName: 'FlowComponent'
});
const AuthenticatedComponent = withAuth(Dashboard)
const SecondStepComponent = withFlow("first-step-finished")(SecondStep)
const ThirdStepComponent = withFlow("second-step-finished")(ThirdStep)
You can easily create an authenticated stream step by composing an HOC:
const AuthSecondStepComponent = withAuth(withFlow("first-step-finished")(SecondStep))
The only thing that is important is that you correctly update your state of reduction during the step. When the user completes the first step, you will install
state.flow["first-step-finished"] = true
so that when the user manually goes to a specific page, he does not have such a state of redundancy, since it was in memory and was redirected to the route redirectPath.
source
share