Akhi21
Akhi21

Reputation: 229

How to use react-router to make sure it works in Reactjs

Here is my Sandbox code https://codesandbox.io/s/wispy-glitter-spgch?file=/src what i am trying to do is on click of LOGIN Button trying to rendering the Dashboard page the url does go to the path '/dashboard'but do not render anything I am not able to find the error I have done routing in a component and passed that component inside of Context API

On page refresh i.e. in '/dashboard' dashboard section it again goes to login part how to maintain this with state

Upvotes: 1

Views: 42

Answers (1)

alishi973
alishi973

Reputation: 65

Use exact parameter in protected route like this:

<ProtectedRoute
        path="/dashboard"
        exact
        auth={authState.isAuthenticated}
        component={Dashboard}
/>

Upvotes: 1

Related Questions