项目作者: LeonardoGentile

项目描述 :
Example project for react-mobx-router5
高级语言: JavaScript
项目地址: git://github.com/LeonardoGentile/react-mobx-router5-example.git


react-mobx-router5-example

This is a simple setup example for the react-mobx-router5 project.

Install and Run

  • Fork, clone, or download the project:
  1. git clone https://github.com/LeonardoGentile/react-mobx-router5-example.git
  • Then install the dependencies:
  1. npm install
  • Run development server:
  1. npm start

Open the web browser to http://localhost:8888/

Routes and Nodes

The project uses this routes configuration:

  1. export default [
  2. { name: 'home', path: '/', component: Home},
  3. { name: 'login', path: '/login', component: Login},
  4. { name: 'index', path: '/index/:id', component: Index},
  5. { name: 'section', path: '/section', component: Sections, children: [
  6. // Sections
  7. { name: 'home', path: '/home', component: Home },
  8. { name: 'login', path: '/login', component: Login },
  9. { name: 'index', path: '/index/:id', component: Index },
  10. { name: 'subsection', path: '/subsection', component: SubSections, children: [
  11. // Subsections
  12. { name: 'home', path: '/home', component: Home },
  13. { name: 'login', path: '/login', component: Login },
  14. { name: 'index', path: '/index/:id', component: Index }
  15. ]}
  16. ]}
  17. ];

That means that the nodes of this app are:

  • '' the root node, see the Main component
  • 'section', see the Sections component
  • 'section.subsection', see the Subsections component

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.