-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Nested text can not be styled with reanimated - backgroundColor, color and etc #1455
Comments
Why do you want to put the <Animated.Text style={{ marginTop: 20 }}>
<Animated.Text
style={{
fontSize: 20,
backgroundColor: Animated.interpolateColors(pressedState, {
inputRange: [0, 1],
outputColorRange: ['transparent', '#bbb'],
}),
}}>
This text can not be animated
</Animated.Text>
</Animated.Text> I think we can resolve it with <View style={{ marginTop: 20 }}>
<Animated.Text
style={{
fontSize: 20,
backgroundColor: Animated.interpolateColors(pressedState, {
inputRange: [0, 1],
outputColorRange: ['transparent', '#bbb'],
}),
}}>
This text can not be animated
</Animated.Text>
</View> |
@hoangtrucit I do it because I want to stylize only part of the text (in real life structure look like this: |
Hey @Strate
The React Native change the structure to:
The
|
## Description I added to documentation information about the impossibility of animating a virtual component. For example we can’t animate nested `<Text>` components because React Native change ``` <Text> string1 <Text>string2</Text> </Text> ``` to ``` <RCTTextView> string1 <RCTVirtualText>string2</RCTVirtualText> </RCTTextView> ``` and the `RCTVirtualText` is a virtual component. It is related with issue: #1455 ## Changes - Updated `about.md` docs ## Checklist - [x] Updated documentation
@piaskowyk This issue should be re-opened, because using 2024-01-09.09.57.47.mp4 |
I've got it working by wrapping Animated.Text into an additional Text: <Text style={styles.word}>
{value.slice(0, highlightSymbolAt)}
<Text>
<Animated.Text style={[animatedStyle]}>{value[highlightSymbolAt]}</Animated.Text>
</Text>
{value.slice(highlightSymbolAt + 1)}
</Text> 2024-01-09.12.26.04.mp4 |
@mlazari have you anyone else figured out if this is possible? @yuriyyakym for me your solution doesn't work, nested text still isn't animatable |
@audrius-savickas I have not. |
It might be worth opening this issue back up since this is no longer a note about this in the 3.x / 4.x docs 😄 |
Description
Hello, I'm trying to stylize
<Text>
which is nested to other<Text>
, but in this case styling is not applied.Steps To Reproduce
See snack example
Expected behavior
Nested text's backgroundColor, color and other styles which can be applied to nested text support animation
Actual behavior
Nested text's backgroundColor, color and other styles which can be applied to nested text don't support animation
Snack or minimal code example
https://snack.expo.io/ZrEZ2NTsc
Package versions
The text was updated successfully, but these errors were encountered: