Skip to content

Commit 11153d7

Browse files
authored
[docs] Replace useRef with useAnimatedValue in Animated example (facebook#4984)
1 parent b8da04e commit 11153d7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

docs/animated.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@ Don't modify the animated value directly. You can use the [`useRef` Hook](https:
1616
The following example contains a `View` which will fade in and fade out based on the animated value `fadeAnim`
1717

1818
```SnackPlayer name=Animated%20Example
19-
import React, {useRef} from 'react';
19+
import React from 'react';
2020
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
21-
import {Animated, Text, View, StyleSheet, Button} from 'react-native';
21+
import {
22+
Animated,
23+
Text,
24+
View,
25+
StyleSheet,
26+
Button,
27+
useAnimatedValue,
28+
} from 'react-native';
2229
2330
const App = () => {
2431
// fadeAnim will be used as the value for opacity. Initial Value: 0
25-
const fadeAnim = useRef(new Animated.Value(0)).current;
32+
const fadeAnim = useAnimatedValue(0);
2633
2734
const fadeIn = () => {
2835
// Will change fadeAnim value to 1 in 5 seconds

0 commit comments

Comments
 (0)