[英]Why is react-router not picking up a route that is not matched exactly when “exact” is not turned on?
I have the following situation: 我有以下情况:
render() {
let redirectRoute = window["reactRoute"];
if (redirectRoute !== undefined) {
window["reactRoute"] = undefined;
return <Redirect to={redirectRoute} push={true} />;
}
return (
<div className="otherContentContainer">
<Route path="/validation" render={() => <p>TestRender</p>} />
</div>
);
}
The listed snippet above is a boiled down and simplified version of the affected render()
in my case. 上面列出的代码段是我所用的
render()
简化版本。
What's going on here is the following: My ASP.NET backend server returns a view which contains a subroute in window["reactRoute"]
(This is something I came up with to get around the client-server routing problem with ASP.NET & React routing). 这是怎么回事:我的ASP.NET后端服务器返回一个视图,该视图在
window["reactRoute"]
包含一个子路由(这是我想出的解决ASP.NET和客户端-服务器路由问题的方法。反应路由)。
It then properly redirects to the following URL: 然后,它将正确重定向到以下URL:
/Logon/validation/success
After the redirect is successful, the redirect part is not relevant anymore and I try to render certain components, in this case a simple <p>
for testing purposes based on that route. 重定向成功后,重定向部分不再重要,我尝试渲染某些组件,在这种情况下,将基于该路由使用简单的
<p>
进行测试。
However, <Route path="/validation" render={() => <p>TestRender</p>} />
does not trigger at all, and I don't understand why. 但是,
<Route path="/validation" render={() => <p>TestRender</p>} />
根本不会触发,我也不知道为什么。
Here is what I picked up from the React router docs: 这是我从React路由器文档中挑选的:
Given that I didn't configure my <Route>
to be exact
, I don't quite see how I am different to the example. 鉴于我没有
exact
配置<Route>
,所以我不太明白与示例有何不同。
Can you point me to where I'm going wrong? 您能指出我要去哪里了吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.