-
-
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
Fix <Route component /> type #6327
Conversation
Thanks for the PR, @eXon 😅 Can we just use a |
It looks like the tests are failing only because the Also, correct me if I'm wrong (which I probably am!) -- but if we're not spying on |
@mjackson PropType.object is just any object. react-is (under the hood) will do a more comprehensive check for it's element-ness. |
I created a new PR for this that addresses the feedback here, while also cleaning up some parts as well. #6417 |
Closing this in favor of #6417 |
The
<Route component />
prop type at the moment is a function. However, if the component has a forwardRefYou might not have the control over this if using third-party HOC on your component. As an example, I use
withCookies
on my routed component. The result would be aforwardRef
because the HOC make sure you still can use ref on your original component.To fix this, we need a better prop-types. Unfortunately, making it reliable isn't as simple as it might look like. There is already a PR to add
PropTypes.elementType
to the officialprop-types
library. For now, there is a library with the same code (prop-types-elementtype
).I've added a failing test and added the better prop-types.
Let me know if I need to do anything else to get this merged!