Answer the question
In order to leave comments, you need to log in
React Native: Why doesn't a component render after a redirect?
I am writing an application on RN and decided to enable routing via react-router-native .
const state = {
authStore: {
isAuth: true,
}
};
const PrivateRoute = ({ component: Component, ...rest }) => (
<Route
{...rest}
render={props =>
state.authStore.isAuth ? (
<Component {...props} />
) : (
<Redirect
to={{
pathname: '/login',
state: { from: props.location },
}}
/>
)}
/>
);
<Provider store={store}>
<NativeRouter>
<View>
<Container>
<Route path="/registration" component={Registration} />
<Route path="/login" component={Login} />
<PrivateRoute path="/" component={Masters} />
</Container>
</View>
</NativeRouter>
</Provider>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question