diff --git a/packages/react-native/Libraries/Utilities/useRefEffect.js b/packages/react-native/Libraries/Utilities/useRefEffect.js index 8f9ed0b3842d..e1e38a0dd7ac 100644 --- a/packages/react-native/Libraries/Utilities/useRefEffect.js +++ b/packages/react-native/Libraries/Utilities/useRefEffect.js @@ -10,8 +10,6 @@ import {useCallback, useRef} from 'react'; -type CallbackRef = T => unknown; - /** * Constructs a callback ref that provides similar semantics as `useEffect`. The * supplied `effect` callback will be called with non-null component instances. @@ -28,7 +26,7 @@ type CallbackRef = T => unknown; */ export default function useRefEffect( effect: TInstance => (() => void) | void, -): CallbackRef { +): React.RefCallback { const cleanupRef = useRef<(() => void) | void>(undefined); return useCallback( (instance: null | TInstance) => { diff --git a/packages/react-native/src/private/animated/createAnimatedPropsHook.js b/packages/react-native/src/private/animated/createAnimatedPropsHook.js index 0e930cdae4a0..b6dcef3bd329 100644 --- a/packages/react-native/src/private/animated/createAnimatedPropsHook.js +++ b/packages/react-native/src/private/animated/createAnimatedPropsHook.js @@ -35,11 +35,10 @@ type ReducedProps = { collapsable: boolean, ... }; -type CallbackRef = T => unknown; export type AnimatedPropsHook = ( props: TProps, -) => [ReducedProps, CallbackRef]; +) => [ReducedProps, React.RefCallback]; type UpdateCallback = () => void; @@ -55,7 +54,7 @@ export default function createAnimatedPropsHook( return function useAnimatedProps( props: TProps, - ): [ReducedProps, CallbackRef] { + ): [ReducedProps, React.RefCallback] { const [, scheduleUpdate] = useReducer(count => count + 1, 0); const onUpdateRef = useRef(null); const timerRef = useRef(null); diff --git a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js index 3aa30acc36ac..81eac46a8e49 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js @@ -563,7 +563,9 @@ class SelectionExample extends React.Component< onChangeText={value => this.setState({value})} // $FlowFixMe[method-unbinding] added when improving typing for this parameters onSelectionChange={this.onSelectionChange.bind(this)} - ref={textInput => (this._textInput = textInput)} + ref={textInput => { + this._textInput = textInput; + }} selection={this.props.imperative ? undefined : this.state.selection} style={this.props.style} value={this.state.value} diff --git a/packages/rn-tester/js/examples/Timer/TimerExample.js b/packages/rn-tester/js/examples/Timer/TimerExample.js index a80bdbac9f65..d9417d4c33b6 100644 --- a/packages/rn-tester/js/examples/Timer/TimerExample.js +++ b/packages/rn-tester/js/examples/Timer/TimerExample.js @@ -297,7 +297,9 @@ class IntervalExample extends React.Component< return ( (this._timerTester = ref)} + ref={ref => { + this._timerTester = ref; + }} dt={25} type="setInterval" />