Created
June 8, 2022 03:08
-
-
Save PrasathRavichandran/5788d7f098d75ce847ba64521ecea19f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {Button,View} from 'react-native'; | |
import Animated, { useSharedValue, useAnimatedStyle } from 'react-native-reanimated'; | |
function App() { | |
const sharedValue = useSharedValue(0); | |
const boxStyle = useAnimatedStyle(() => { | |
return { | |
width: 100, | |
height: 100, | |
backgroundColor: 'red', | |
// Animate translateX | |
transform: [{ translateX: x.value }], | |
} | |
}); | |
return ( | |
<View> | |
<Button title="Increment x" onPress={() => sharedValue.value += 1} /> | |
<Animated.View style={boxStyle} /> | |
</View> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment