Reputation: 567
I'm using react router and getting this warning:
[react-router] You cannot change <Router routes>; it will be ignored.
Though everything works properly I still can't get out of this warning. Can anybody tell what can cause such warning?
here's an example of my router
render () {
return (
<div>
<Router history={this.history}>
<Route path='/' component={PageLanding} />
<Route path='/test' onEnter={CheckUser.CheckUser} component={PageTest} />
<Route path='*' component={NotFoundPage} />
</Router>
</div>
)
}
Upvotes: 1
Views: 208
Reputation: 487
If you are using react-router "^3.0.2" use following structure
<Router history={hashHistory}>
<Route path='/' component={mainComponentName} />
<Route path='/componentRefName' component={componentName} />
<Route path='/componentRefName' component={componentName} />
</Router>,
If you are using react-router "4.0" use following structure
<HashRouter>
<div>
<Route exact path="/" component={mainComponentName} ></Route>
<Route path="/componentRefName" component={componentName}></Route>
<Route path="/componentRefName" component={componentName}></Route>
</div>
</HashRouter>
Upvotes: 1