ReactJS react-router RoutingContext

ole*_*hko 6 javascript node.js reactjs react-router

我正在使用ReactJS和react-router模块构建同构应用程序,以便在服务器端进行路由.

从其关于在服务器上使用react-router的指南:

(req, res) => {      
  match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {
    //...

    else if (renderProps) {
      res.status(200).send(renderToString(<RoutingContext {...renderProps} />))
    } 

    //...
  })
}
Run Code Online (Sandbox Code Playgroud)

几乎没有关于此RoutingContext的信息.所以对我来说有点不清楚它是如何工作的.它是Router来自react-router(在其他路由之上使用)的组件的某种替代品吗?

任何理解的帮助将非常感谢!

Flo*_*ent 2

RoutingContext是一个未记录的功能,将在 v2.0.0 中被替换RouterContext。它的作用是同步渲染路由组件。

它只是组件的包装器,用于注入上下文属性,例如historylocationparams