-
Notifications
You must be signed in to change notification settings - Fork 4
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
Switch from findDOMNode() to refs #100
Comments
Hmm, I'll do some digging. render() {
if (typeof this.props.children === "function") {
return this.props.children(this.state.size);
} else if (this.props.children) {
return this.props.children;
}
return null;
} This means I can't simply just use the I could, however add support for a new prop that accepts the element from the outside, in which case you'd be able to do render like this: // `this.saveRef` saves the element as `this.element` to be used with the
// ContainerQuery component
<ContainerQuery meta={meta} element={this.element}>
<div ref={this.saveRef}>...</div>
</ContainerQuery> In which case the component wouldn't call findDOMNode internally. Would that work for you? |
That's a cool idea. Any ideas how we could get this to work with the higher order function |
I think there's a solution to that too, but I'd need to drop the wrappedComponentRef prop to make my job easier. Don't suppose you use that prop?@tjbenneche If that's fine with you, then I'll add it to v3. |
Nope, I don't use that! So sounds good to me |
So I've experimented a little, but unfortunately I can't replace findDOMNode in withContainerQuery. I could technically add an extra "element" argument to withContainerQuery, but when you call that function, you don't actually have access to the wrapped component's root dom element, so it doesn't help. I'll experiment with the ContainerQuery prop, because I'm pretty sure that can be solved. |
@tjbenneche the latest alpha should solve your issue: Here's an example on how to use the new ContainerQuery component: |
This should now be fixed with v3 |
For components using
container-query
, snapshot tests fail because of the use offindDOMNode()
in the library. This limitation is referenced in storybook's documentation here: This can be useful while testing react components which make use of the findDomNode API since they always fail with snapshot testing while using react-test-rendererThe invariant violation error I get is referenced in the core react repo here
It sounds like other projects have been able to avoid this issue by using
refs
instead of thefindDOMNode
API, for example: ianstormtaylor/slate#708The text was updated successfully, but these errors were encountered: