Skip to content

Commit

Permalink
Animated: Revert setNativeView Workaround
Browse files Browse the repository at this point in the history
Summary:
Reverts {D41122065 (1b1b26a)}, which is no longer necessary because {D41208895 (7cf4cf3)} fixed the `ref` invalidation in `ScrollView`.

Changelog:
[Internal]

Reviewed By: sammy-SC

Differential Revision: D41390543

fbshipit-source-id: 36c3db80af6e426f233ef0aaf5909942fb7103b2
  • Loading branch information
yungsters authored and facebook-github-bot committed Nov 22, 2022
1 parent 6410a62 commit 3eb69f2
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions Libraries/Animated/useAnimatedProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
): [ReducedProps<TProps>, CallbackRef<TInstance | null>] {
const [, scheduleUpdate] = useReducer<number, void>(count => count + 1, 0);
const onUpdateRef = useRef<?() => void>(null);
const cachedRef = useRef<TInstance | null>(null);

// TODO: Only invalidate `node` if animated props or `style` change. In the
// previous implementation, we permitted `style` to override props with the
Expand Down Expand Up @@ -65,7 +64,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
// NOTE: This may be called more often than necessary (e.g. when `props`
// changes), but `setNativeView` already optimizes for that.
node.setNativeView(instance);
cachedRef.current = instance;

// NOTE: This callback is only used by the JavaScript animation driver.
onUpdateRef.current = () => {
Expand Down Expand Up @@ -115,16 +113,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
);
const callbackRef = useRefEffect<TInstance>(refEffect);

useEffect(() => {
// Call `setNativeView` any time `node` changes to make sure
// `AnimatedProps._animatedView` is up to date.
// This would not be necessary in an ideal world.
// In React, anytime identity of function passed to `ref` changes,
// the old function is called with null and the new function is called with value.
// ScrollView does not behave like this and this workaround is necessary.
node.setNativeView(cachedRef.current);
}, [node]);

return [reduceAnimatedProps<TProps>(node), callbackRef];
}

Expand Down

0 comments on commit 3eb69f2

Please sign in to comment.