Skip to content

Commit 3c1d94e

Browse files
committed
docs: fix animation examples to use reanimated components only when animation is actually needed
1 parent c16f36e commit 3c1d94e

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

docs/guide/animations.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ You can also use individual animation properties:
161161

162162
## Using with Reanimated Components
163163

164-
CSSX animations work with Reanimated v4's animated components:
164+
CSSX animations work with Reanimated v4's animated components.
165+
166+
**Important:** Only use `Animated.*` components on elements that have `animation` or `transition` in their styles. Elements with static styles should use regular React Native components (`View`, `Text`, etc.).
165167

166168
```jsx
167169
import { styl } from 'cssxjs'
@@ -250,15 +252,17 @@ A notification toast with enter and exit animations:
250252

251253
```jsx
252254
import { styl } from 'cssxjs'
253-
import { Pressable } from 'react-native'
255+
import { Pressable, Text } from 'react-native'
254256
import Animated from 'react-native-reanimated'
255257

256258
function Toast({ message, visible, onHide }) {
259+
// Only the outer View needs Animated since it has animation
260+
// Text elements use regular RN components (no animation on them)
257261
return (
258262
<Animated.View styleName={['toast', { visible, hidden: !visible }]}>
259-
<Animated.Text styleName="message">{message}</Animated.Text>
263+
<Text styleName="message">{message}</Text>
260264
<Pressable onPress={onHide}>
261-
<Animated.Text styleName="close">×</Animated.Text>
265+
<Text styleName="close">×</Text>
262266
</Pressable>
263267
</Animated.View>
264268
)

0 commit comments

Comments
 (0)