question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid prop `path` of type `regexp` supplied to `Route`, expected `string`

See original GitHub issue

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 type regexp supplied to Route, expected string. in Route

react-router-dom@4.3.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kevichcommented, Oct 26, 2018

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 (?!something) than using it as RegExp

0reactions
Fi1osofcommented, Oct 25, 2018

@pshrmn, thank you for the clarification. OK.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid prop `path` of type `regexp` supplied to `Route ... - GitHub
Warning: Failed prop type: Invalid prop path of type regexp supplied to Route , expected string . in Route. react-router-dom@4.3.1.
Read more >
Failed prop type: Invalid prop `path` supplied to `Route`
I'm providing a regular expression to a react-router Route like this: <Router> <Route path={/\/(?!path-to-exclude)/gi} component={Navbar}/> ...
Read more >
reactjs/react-router - Gitter
Hello guys! What is wrong whne I get Warning: Failed prop type: Invalid prop 'component' of type 'object' supplied to 'Route', expected ...
Read more >
react-router - UNPKG
+\n 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'\n );\n } else {\n printWarning('Invalid argument supplied to...
Read more >
Migrating to React Router v6: A complete guide
Migrate your React Router applications from v5 to v6 with this in-depth guide, including a review of additions and improvements from v5.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found