用react-react router history写了给例子,但是老不成功,有没有实现成功的

React Render React-Router Async Component On Server Side - React 中文
21:50:35 UTC
React-Router在服务端Render有非常不错的体验。就是只需要一个中间件可以实现任何地址的服务端Render,如一下代码,但是如果Component需要初始化的数据时,就没办法处理了,
app.get('*',function (req, res) {
// pass in `req.url` and the router will immediately match
Router.run(routes, req.path, function (routeHandler) {
var routeComponent=React.createFactory(routeHandler)
var content = React.renderToString(routeComponent());
res.render('index/index', {content: content});
在google上搜了 React-Async 可以很方便实现服务端Render 但是需要安装fibers现在npm 怎么也装不上fibers 所以只有找其他方法了,不知道有同学对服务端Render有没有更好的方案?整个项目 用到了Reflux React-Router
mongoose github地址:
浙ICP备号-3

我要回帖

更多关于 react router github 的文章

 

随机推荐