UNPKG

create-expo-cljs-app

Version:

Create a react native application with Expo and Shadow-CLJS!

49 lines (47 loc) 1.29 kB
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format * @flow */ 'use strict'; import type { ElementRef, Ref } from 'react'; type Args = $ReadOnly<{| getForwardedRef: () => ?Ref<any>, setLocalRef: (ref: ElementRef<any>) => mixed, |}>; /** * 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(arg0: Args): (ref: ElementRef<any>) => void; export default setAndForwardRef;