[英]React router get current route outside component
I am now using fluxible with react-router, I want to perform action and then redirect after the callback. 我现在使用fluxable与react-router,我想执行操作然后在回调后重定向。
In the action, the action context has no router and fail to change the route after the action. 在操作中,操作上下文没有路由器,并且在操作后无法更改路由。
I have tried to find example but I can only found using browserHistory. 我试图找到示例,但我只能找到使用browserHistory。
I can now push the browserHistory but somehow I can't find the current path. 我现在可以推送浏览器历史记录,但不知怎的,我找不到当前的路径。 (because my new path is the depends on the current path /:id/profile, and then I want to redirect to /:id/details/:version), So I need to get back /:id/details before I append the version). (因为我的新路径取决于当前路径/:id / profile,然后我想重定向到/:id / details /:version),所以我需要在追加之前取回/:id / details版)。
How to find the current route in the action where I can only access the action context without router instance? 如何在我只能访问没有路由器实例的操作上下文的操作中找到当前路由?
Sometimes my react router works on server side but not client side. 有时我的反应路由器在服务器端工作,但不在客户端工作。 It will show when I refresh the page but 404 when in client side only.( I guess because I am using the relative link) 它将在我刷新页面时显示,但仅在客户端时显示404。(我猜因为我使用的是相对链接)
Does react router support relative link in the ? 反应路由器是否支持相对链接?
Thanks 谢谢
For the Question 3, I have figured out the method to access the params 对于问题3,我已经找到了访问参数的方法
In fact, the second argument in the stateless component is context. 实际上,无状态组件中的第二个参数是上下文。 I have pass the params and obtain there. 我已经通过了参数并在那里获得了。
eg 例如
const CompanyDetail = (props, context) => {
}
CompanyDetail.contextTypes = {
params: PropTypes.object,
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.