Skip to content

Commit 3eb69f2

Browse files
yungstersfacebook-github-bot
authored andcommitted
Animated: Revert setNativeView Workaround
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
1 parent 6410a62 commit 3eb69f2

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

Libraries/Animated/useAnimatedProps.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
3535
): [ReducedProps<TProps>, CallbackRef<TInstance | null>] {
3636
const [, scheduleUpdate] = useReducer<number, void>(count => count + 1, 0);
3737
const onUpdateRef = useRef<?() => void>(null);
38-
const cachedRef = useRef<TInstance | null>(null);
3938

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

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

118-
useEffect(() => {
119-
// Call `setNativeView` any time `node` changes to make sure
120-
// `AnimatedProps._animatedView` is up to date.
121-
// This would not be necessary in an ideal world.
122-
// In React, anytime identity of function passed to `ref` changes,
123-
// the old function is called with null and the new function is called with value.
124-
// ScrollView does not behave like this and this workaround is necessary.
125-
node.setNativeView(cachedRef.current);
126-
}, [node]);
127-
128116
return [reduceAnimatedProps<TProps>(node), callbackRef];
129117
}
130118

0 commit comments

Comments
 (0)