mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 14:48:25 +00:00
Summary: This PR introduces a new helper function called `setAndForwardRef`. It is intended to help with moving components that depend on `NativeMethodsMixin` off of `createReactClass`. It allows for classes that depend on having a ref to a native component to be able to also forward the native component ref to user code. Usage is like this: ```js class MyView extends React.Component { _nativeRef = null; _setNativeRef = setAndForwardRef({ getForwardedRef: () => this.props.forwardedRef, setLocalRef: ref => { this._nativeRef = ref; }, }); render() { return <View ref={this._setNativeRef} />; } } const MyViewWithRef = React.forwardRef((props, ref) => ( <MyView {...props} forwardedRef={ref} /> )); module.exports = MyViewWithRef; ``` Pull Request resolved: https://github.com/facebook/react-native/pull/21823 Differential Revision: D10436673 Pulled By: TheSavior fbshipit-source-id: 32e167bb3ea3234f08d5715168b0e61e4e035a7c