react-router使用了historyLocation后,回退按钮触发history改变,但没有正确显示上个页面的内容。react有提供history change的callback吗?扫文档貌似没见着
React-router回退无法正确页面的内容
zuiwosuifeng
#3
module引入就略掉了,主要代码就是这样子的,在点击回退按钮时只是url里面的地址变化,页面内容没有变化,不知道哪里用的姿势不对,请大神指点~
客户端代码:
Router.run(
routes,
Router.HistoryLocation,
Root => {
React.render(
<Root />,
document.getElementById('app')
);
}
);
服务端代码
Router.run(routes, req.url, (Root, state) => {
fetch(state.routes, state.params, (code) => {
return res.render(
'wise',
{
app: React.renderToString(
React.createElement((Root))
)
}
);
});
});
路由代码:
const routes = [
<Route name="root" path="/lineQuery/" handler={APP}>
<Route name="cate" path=":cate_tag" handler={TravelCate}>
<Route name="prov" path=':pro' handler={Province}>
<Route name="type" path=':type_id' handler={TravelType} />
</Route>
</Route>
<DefaultRoute handler={TravelCate} />
<NotFoundRoute handler={NotFound} />
</Route>
];
export default routes;