Last active
August 8, 2020 05:31
-
-
Save spencerfeng/e9d5d7de094c40275f72566d6b89a4f6 to your computer and use it in GitHub Desktop.
This gist is used in this medium article: When React Native Reanimated nodes get evaluated
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
const UseCodeInputNodeUpdatedExample = () => { | |
const [toggled, setToggled] = useState(false) | |
const destValue = useRef<Value<number>>(new Value(0)) | |
const opacity = useRef<Value<number>>(new Value(0)) | |
useCode(() => [debug('console log in useCode 1', destValue.current)], []) | |
useCode(() => [debug('console log in useCode 2', opacity.current)], []) | |
useEffect(() => { | |
destValue.current.setValue(toggled ? 1 : 0) | |
}, [toggled]) | |
return ( | |
<View> | |
<Button | |
onPress={() => setToggled((prev) => !prev)} | |
title="Toggle" | |
color="#000000" | |
accessibilityLabel="Toggle Button" | |
/> | |
</View> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment