-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid prop path
of type regexp
supplied to Route
, expected string
#6418
Comments
Regex isn't allowed in the path. We cache our generated regexps, so this would break that. |
@timdorr, so this is undocumented features. And it should be allowed. Because it works. Have a look: https://codesandbox.io/s/yv2z0x7qo1 |
It may technically work, but it shouldn't be encouraged.
Using a RegExp path can also cause issues. What happens if you want to nest a route as a child of a route whose path is a RegExp? With strings you can grab |
@pshrmn, thank you for the clarification. OK. |
I think technically there is no problem to convert RegExp to strings on react-router level, so that it will behave pretty the same as now. Even concatenating is ok, since even now there is kind of support RegExp in stings with custom match parameters, and it will be the same issue either with text with RegExp or real RegExp. So it should be up to developer not to shoot into his own leg with that concatenations. Still my point is if react-router uses path-to-regexp, it should support all of it's features. But for what it's really needed to be supported as RegExp by react-router is because of this issue in pillarjs/path-to-regexp#99. And for now there is no other way to use |
Version
PropTypes require String or [String] for Route, but Route allow use regex too.
Test Case
https://codesandbox.io/s/yv2z0x7qo1 (See route for topics).
Expected Behavior
No warnings.
Allow types: String, RegExp, [String, RegExp]
Actual Behavior
Warning: Failed prop type: Invalid prop
path
of typeregexp
supplied toRoute
, expectedstring
.in Route
react-router-dom@4.3.1
The text was updated successfully, but these errors were encountered: