UNPKG

@react-native-community/checkbox

Version:

React Native Checkbox native modules for Android , iOS and Windows

41 lines (40 loc) 1.13 kB
/** * Imported from RN .71 */ import type { ElementRef } from 'react'; declare type Args = { getForwardedRef: () => React.Ref<any> | undefined; setLocalRef: (ref: ElementRef<any>) => any; }; /** * This is a helper function for when a component needs to be able to forward a ref * to a child component, but still needs to have access to that component as part of * its implementation. * * Its main use case is in wrappers for native components. * * Usage: * * 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; */ declare function setAndForwardRef({ getForwardedRef, setLocalRef, }: Args): (ref: ElementRef<any>) => void; export default setAndForwardRef;