我正在为 react-router
路由提供一个正则表达式,如下所示:
<Router>
<Route path={/\/(?!path-to-exclude)/gi} component={Navbar}/>
<Route path={/\/(?!path-to-exclude)/gi} component={ChatModal}/>
...
</Router>
这显然是有效的,因为当路由与正则表达式匹配时这些组件不会显示,但是我在控制台中收到此警告:
Warning: Failed prop type: Invalid prop `path` supplied to `Route`.
in Route (at App.js:45)
in App (created by ConnectFunction)
in ConnectFunction (at src/index.js:15)
in StrictMode (at src/index.js:14)
in Provider (at src/index.js:13)
是否有适当的方法为 react-router 路径提供正则表达式或排除路径中的某些匹配项?