Skip to content

Instantly share code, notes, and snippets.

@PrasathRavichandran
Created June 8, 2022 03:08
Show Gist options
  • Save PrasathRavichandran/5788d7f098d75ce847ba64521ecea19f to your computer and use it in GitHub Desktop.
Save PrasathRavichandran/5788d7f098d75ce847ba64521ecea19f to your computer and use it in GitHub Desktop.
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