The main API into react router. It runs your routes, matching them against a location, and then calls back with the next state for you to render.

// src/index.react.js
run(appRoutes, function (Handler, state) {
  React.render(<Handler />, document.body);

我们项目的appRoutes路由规则放在app-routes.react.js中,通过import appRoutes from './app-routes.react'引入,我们会在之后对路由规则进行介绍。

Signature, [location,] callback(Root, state))


  • Root

A ReactComponent class with the current match all wrapped up inside it, ready for you to render.

  • state

An object containing the matched state.

Basic Usage, function (Root) {
  // whenever the url changes, this callback is called again
  React.render(<Root/>, document.body);