Skip to content
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(react-router): Allow string and object refs in withRouter #6680

Merged
merged 2 commits into from May 15, 2019

Conversation

eps1lon
Copy link
Contributor

@eps1lon eps1lon commented Apr 1, 2019

Doesn't warn about createRef or useRef values in wrappedComponentRef

@timdorr
Copy link
Member

timdorr commented Apr 1, 2019

@eps1lon
Copy link
Contributor Author

eps1lon commented Apr 1, 2019

Right you still support string refs. I'm not familiar with those. Do they even work when forwarded?

I'm not sure I agree with the shape definition here. TL;DR; react already warns if the shape is bad:

Warning: Unexpected ref object provided for div. Use either a ref-setter function or React.createRef().

The wrapped component is most likely not a host component. It might be a ref forwarding component that results in the ref being attached to a host component but that's again not guaranteed. PropTypes.shape({ current: PropTypes.any }) should report no false positives. However, I don't really understand why you check for the current value. It won't be read as far as I can tell. It's probably intended to catch changes in the type? I don't think that's a helpful assumption.

@eps1lon eps1lon changed the title fix(react-router): Don't warn about ref objects fix(react-router): Allow string and object refs in withRouter May 15, 2019
@eps1lon
Copy link
Contributor Author

eps1lon commented May 15, 2019

Updated to allow string refs. Still think the shape check is unnecessary since react already warns about this.

@timdorr Anything left to do?

@timdorr
Copy link
Member

timdorr commented May 15, 2019

Nope, looks good. Thanks!

@timdorr timdorr merged commit 56c829b into remix-run:master May 15, 2019
@eps1lon eps1lon deleted the patch-1 branch May 15, 2019 12:19
@lock lock bot locked as resolved and limited conversation to collaborators Jul 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants