This is a simple setup example for the react-mobx-router5 project.
- Fork, clone, or download the project:
git clone https://github.com/LeonardoGentile/react-mobx-router5-example.git
- Then install the dependencies:
npm install
- Run development server:
npm start
Open the web browser to http://localhost:8888/
The project uses this routes configuration:
export default [
{ name: 'home', path: '/', component: Home},
{ name: 'login', path: '/login', component: Login},
{ name: 'index', path: '/index/:id', component: Index},
{ name: 'section', path: '/section', component: Sections, children: [
// Sections
{ name: 'home', path: '/home', component: Home },
{ name: 'login', path: '/login', component: Login },
{ name: 'index', path: '/index/:id', component: Index },
{ name: 'subsection', path: '/subsection', component: SubSections, children: [
// Subsections
{ name: 'home', path: '/home', component: Home },
{ name: 'login', path: '/login', component: Login },
{ name: 'index', path: '/index/:id', component: Index }
]}
]}
];That means that the nodes of this app are:
''the root node, see theMaincomponent'section', see theSectionscomponent'section.subsection', see theSubsectionscomponent
All this components should be wrapped with routeNode HOC.
Notice that routeNode HOC injects an observable route, a non-observable plainRoute and a (mobx-router5) routerStore prop to the wrapped component.
Each one of these uses in turn the RouteView component, resposnsible to select and render the various
subcomponent.
Notice that a RouteView component injects a route prop to the newly created component.
The better way to learn about react-mobx-router5 is to view the source code and play around with this example.
If you have any trouble or doubt please open an issue either here or on react-mobx-router5 repo.