Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/react-native/Libraries/Utilities/useRefEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import {useCallback, useRef} from 'react';

type CallbackRef<T> = T => unknown;

/**
* Constructs a callback ref that provides similar semantics as `useEffect`. The
* supplied `effect` callback will be called with non-null component instances.
Expand All @@ -28,7 +26,7 @@ type CallbackRef<T> = T => unknown;
*/
export default function useRefEffect<TInstance>(
effect: TInstance => (() => void) | void,
): CallbackRef<TInstance | null> {
): React.RefCallback<TInstance> {
const cleanupRef = useRef<(() => void) | void>(undefined);
return useCallback(
(instance: null | TInstance) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ type ReducedProps<TProps> = {
collapsable: boolean,
...
};
type CallbackRef<T> = T => unknown;

export type AnimatedPropsHook = <TProps extends {...}, TInstance>(
props: TProps,
) => [ReducedProps<TProps>, CallbackRef<TInstance | null>];
) => [ReducedProps<TProps>, React.RefCallback<TInstance>];

type UpdateCallback = () => void;

Expand All @@ -55,7 +54,7 @@ export default function createAnimatedPropsHook(

return function useAnimatedProps<TProps extends {...}, TInstance>(
props: TProps,
): [ReducedProps<TProps>, CallbackRef<TInstance | null>] {
): [ReducedProps<TProps>, React.RefCallback<TInstance>] {
const [, scheduleUpdate] = useReducer<number, void>(count => count + 1, 0);
const onUpdateRef = useRef<UpdateCallback | null>(null);
const timerRef = useRef<TimeoutID | null>(null);
Expand Down
Loading