I am building a simple ReactJS page (my first) and I have a problem with the route. The link to the browser panel is updated (there are no errors in the console), but the page is not updated:
My App.js :
return( <div id="container"> <Dashboard>{this.props.children}</Dashboard> </div> );
The toolbar is the main page where dynamic content is displayed in the middle
return( ... <Link to="/memory">Memory</Link> .... <div id="page-wrapper" className="page-wrapper"> {this.props.children} </div> );
So, I created two small components ( Home , which appears at the beginning and Memory )
home
render() { return( <div className="row"> HOMEPAGE </div> ); }
Memory:
render() { return( <div className="row"> MEMORY </div> ); }
The router is very simple:
<Route component={App}> <Route path='/' component={Home}> <Route path='/memory' component={Memory} /> </Route> </Route>
When I go to my home server (localhost: 3000), my HOMEPAGE is displayed, but when I click on the Memory link, nothing happens ... the URL changes, but the Memory component fails ...
UPDATE
Thanks to the answer, I had a working version:
Toolbar → deleted
App.js
return( <div id="container"> <div className="content" id="wrapper"> <Navigation /> <div id="page-wrapper" className="page-wrapper" > {this.props.children || <Home />} </div> </div> </div>
Thus, the navigation will contain only part of the navigation (top panel and left panel).
Route changed:
<Route> <Route path='/' component={App}> <Route path='/memory' component={Memory} /> </Route> </Route>
Now when I go to the homepage (localhost: 3000), the variable this.props.children is undefined and I am pulling out the Home component (thanks {this.props.children || <Home />} ).
In all other cases, I make the right component provided by Link