-
Notifications
You must be signed in to change notification settings - Fork 932
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
validateGetRootPropsCalledCorrectly does not correctly check if the root props are applied #235
Comments
I believe the problem is that you are not using Change const MyDiv = ({innerRef, ...rest}) => <div ref={innerRef} {...rest} /> And then change your call site: <MyDiv {...getRootProps({refKey: 'innerRef'})}>
{/* ... */}
</MyDiv> Here's a working example: https://codesandbox.io/s/m4n2416l1x Closing now, as I believe this resolves the issue. If not, let me know and we can keep discussing. |
In my case I cannot change the definition of MyDiv. Actually, the real case is more complicated than the example (that I greatly simplified in the codesandbox). |
OK. Is there no way to make |
What about transforming the |
If we did that then the component would just not work at all. Failing early and obviously is better. Any reason you couldn't wrap |
I understand your position, but the check is too simplicistic and it is failing even if the component would work because the ref is set correctly to the root component. |
But the component doesn't work. With the way refs work, downshift can't get the root DOM node without being able to pass a ref prop to the node itself. It's not enough to pass a ref to a composite component. Unless I'm mistaken... Feel free to prove me wrong with a pull request. |
Please refer to this example: https://codesandbox.io/s/n3jv69ywnl |
The main point here is that the |
Ah, I see what you mean. Very interesting. Hmmm... I'm trying to think of a good way to keep the error but also allow you to do what you're doing there because I think that it's more likely people are making a mistake when you don't pass a What I'm thinking is that we could add an option you could pass to |
Reopening since this conversation is taking a different direction. |
Maybe instead of |
That's fine with me. And sorry if I was not sufficiently clear since the beginning. |
Yes please! Thank you! |
* Add the option `suppressRefError` to `getRootProps`. Fixes #235. * Add myself as contributor. * Fix Markdown in README. * Add also 'test' as contribution.
…-js#241) * Add the option `suppressRefError` to `getRootProps`. Fixes downshift-js#235. * Add myself as contributor. * Fix Markdown in README. * Add also 'test' as contribution.
|
downshift
version:1.14.0
node
version:npm
(oryarn
) version:Reproduction repository:
https://codesandbox.io/s/23yzon246r
Problem description:
I would like to use a non-DOM component as root component returned by the children function. I pass to it a prop
rootProps
containing the result ofgetRootProps()
and it spreads the object to the inner rootdiv
. In such a way, the root props that Downshift needs are correctly applied. However thevalidateGetRootPropsCalledCorrectly
throws an error.Suggested solution:
I would suggest to either remove the check or to add a prop
excludeSafetyChecks
that allows to bypass such a check.The text was updated successfully, but these errors were encountered: