-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[PoC] feat: support for animating text inside Animated.Text
#8595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
7270154 to
485fd5a
Compare
…a separate example
|
What will be the right way to sync the animation shared value with React state? Should we use a I mean, this is the most common scenario when using this pattern for example, when receiving a number from an API to animate the text. |
|
@RodolfoSilva I think the best way to go is to do it like this: const myValueFromAPI = useValueFromAPI();
const sv = useSharedValue<number>(myValueFromAPI);
useEffect(() => {
sv.value = withTiming(myValueFromAPI);
}, [myValueFromAPI]);
const textSv = useDerivedValue(() => {
return sv.value.toFixed(2);
});
return <Animated.Text text={textSv} />; |
Summary
Work in progress.
Fixes the issue with cropped
TextInputand visible ellipsis.TODO: update docs https://docs.swmansion.com/react-native-reanimated/docs/guides/performance/#-animate-textinput-instead-of-re-rendering-text-component
Test plan