MCPcopy Create free account
hub / github.com/expo/examples / AnimatedStyleUpdateExample

Function AnimatedStyleUpdateExample

with-reanimated/App.js:9–46  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

7import { View, Button } from "react-native";
8
9export default function AnimatedStyleUpdateExample(props) {
10 const randomWidth = useSharedValue(10);
11
12 const config = {
13 duration: 500,
14 easing: Easing.bezier(0.5, 0.01, 0, 1),
15 };
16
17 const style = useAnimatedStyle(() => {
18 return {
19 width: withTiming(randomWidth.value, config),
20 };
21 });
22
23 return (
24 <View
25 style={{
26 flex: 1,
27 alignItems: "center",
28 justifyContent: "center",
29 flexDirection: "column",
30 }}
31 >
32 <Animated.View
33 style={[
34 { width: 100, height: 80, backgroundColor: "black", margin: 30 },
35 style,
36 ]}
37 />
38 <Button
39 title="toggle"
40 onPress={() => {
41 randomWidth.value = Math.random() * 350;
42 }}
43 />
44 </View>
45 );
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected