Migrating a v3 reactive router to v4

I am currently trying to migrate react-router from v3 to v4, but I cannot fully understand the new concepts, my old v3 react-router code looks like this, can someone please take a look and give me some hints?

Thank!

<Router history={ browserHistory }>
     <Route path="/" component={ App }>
       <IndexRoute name="index" component={ Index } />
       <Route name="documents" path="/documents" component={ Documents } onEnter={ authenticate } />
       <Route name="newDocument" path="/documents/new" component={ NewDocument } onEnter={ authenticate } />
       <Route name="editDocument" path="/documents/:_id/edit" component={ EditDocument } onEnter={ authenticate } />
       <Route name="viewDocument" path="/documents/:_id" component={ ViewDocument } onEnter={ authenticate } />
       <Route name="login" path="/login" component={ Login } />
       <Route name="recover-password" path="/recover-password" component={ RecoverPassword } />
       <Route name="reset-password" path="/reset-password/:token" component={ ResetPassword } />
       <Route name="signup" path="/signup" component={ Signup } />
       <Route path="*" component={ NotFound } />
     </Route>
   </Router>

      

+3


source to share


1 answer


Do not insert routes.


Save this part

<Router history={ browserHistory }>
  <Route path="/" component={ App } />
</Router>

      



and move all nested to <App />

(see here ). Also action-router-v4 has no concept <IndexRoute />

(see here ).


Check out the documentation , it's incredible.

+6


source







All Articles