2 ms·
That sounds like the equivalent to React's forward refs. https://reactjs.org/docs/forwarding-refs.html https://reactjs.org/docs/forwarding-refs.html
by onion2k 6y ago
That sounds like the equivalent to React's forward refs. https://reactjs.org/docs/forwarding-refs.html https://reactjs.org/docs/forwarding-refs.html
- acemarke 6y agoNo, that's very different, in two ways. First, `$childRef.setData()` appears to be the conceptual equivalent in React of `childClassComponentInstance.setState({someField})`. While that's technically possible, it's _extremely_ non-idiomatic in React and completely discouraged. Second, "forwarding refs" is a feature specifically designed to allow a component to apply a ref to something _inside_ of itself. For example, the React-Redux `connect` API uses ref forwarding to allow `<ConnectedComponent ref={instanceRef}>` to hand back the inner wrapped component, not the outer wrapper component from the library. It doesn't have anything to do with calling a state setting function on a component in and of itself.