Skip to content

Conversation

@tomekzaw
Copy link
Member

@tomekzaw tomekzaw commented Nov 13, 2025

Summary

Work in progress.

Fixes the issue with cropped TextInput and 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

@tomekzaw tomekzaw force-pushed the @tomekzaw/animated-text branch from 7270154 to 485fd5a Compare November 17, 2025 09:42
@RodolfoSilva
Copy link
Contributor

What will be the right way to sync the animation shared value with React state?

Should we use a useDerivedValue based on the React state, or do we need a useEffect to handle the changes?
(In other words, should we use useEffect or useLayoutEffect to sync React state with a shared value?)

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.

@tomekzaw
Copy link
Member Author

tomekzaw commented Dec 6, 2025

@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} />;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants