Closed thearabbit closed 7 years ago
@thearabbit I'll have to take a look. Off-hand you can only do onEnter
on groups of routes applying to all of them.
Thanks for your reply.
Could you example on base router
?
@thearabbit sure, flagging this as a refactor. For the time being, here's an example:
<Route path="/documents" onEnter={ authenticate }>
<Route name="newDocument" path="new" component={ NewDocument } />
<Route name="editDocument" path=":_id/edit" component={ EditDocument } />
<Route name="viewDocument" path=":_id" component={ ViewDocument } />
</Route>
Thanks again. I will try soon.
Now, I tried but have problem with Document List Page
// Default
<Route name="documents" path="/documents" component={ Documents } onEnter={ authenticate }/>
-------
// Nested
<Route path="/documents" onEnter={ authenticate }>
<Route name="newDocument" path="new" component={ NewDocument } />
Please help me.
@thearabbit make sure to follow the example I posted above. When nesting a route, you need to close the parent route after the child, like this:
<Route path="/documents" onEnter={ authenticate }>
<IndexRoute name="documents" component={ Documents } />
<Route name="newDocument" path="new" component={ NewDocument } />
</Route>
Edit: Just realized you need to add the <IndexRoute />
component for the documents list.
Oh, Look great. Very thanks 👍
Could config
onEnter={ authenticate }
for all? Instead of this: