I used to change texts without rerendering the component using the following code. It works in alpha.8, but after upgrading to alpha.9 it stopped working. Shared value is changing, but the TextInput showing the same 'Initial text'.
I tried to play with different props (children, value, text) and components (Text, TextInput), but without any results.
How can I tweak the code to make it work? Or is there another way to do the job?
Thanks
import React from 'react';
import { View, TextInput, Button } from 'react-native';
import Animated, { useAnimatedProps, useSharedValue } from 'react-native-reanimated';
const AnimatedText = Animated.createAnimatedComponent(TextInput);
const App = () => {
const sharedText = useSharedValue('Initial text');
const textAnimatedProps = useAnimatedProps(() => {
return { text: sharedText.value };
});
let numPresses = 0;
const onButtonPress = () => {
console.log(sharedText.value);
numPresses++;
sharedText.value = `Pressed ${numPresses} times`;
};
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<AnimatedText editable={false} value={sharedText.value} animatedProps={textAnimatedProps} />
<Button title="Button" onPress={onButtonPress} />
</View>
);
};
export default App;

I think some of the internal configurations were updated so now you will need to explicitly add text to the whitelisted native props.
Animated.addWhitelistedNativeProps({ text: true });
Then it will work
Then it will work
It certainly did work. Thank you
Here's the PR changing this behavior for context: #1409.