Created
February 23, 2022 05:29
-
-
Save FaiChou/cbbf5854d9b3efebe92ecb6cc3820000 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
function Detail() { | |
const [x, addOneToX] = React.useReducer(x=>x+1,0); | |
const [, forceUpdate] = React.useReducer(x=>x+1,0); | |
console.log('render: ', x); | |
React.useEffect(() => { | |
console.log('effect: ', x); | |
return function() { | |
console.log('cleanup: ', x); | |
} | |
}, [x]); | |
return ( | |
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> | |
<Text>Detail!</Text> | |
<Button title="x" onPress={addOneToX} /> | |
<Button title="forceupdate" onPress={forceUpdate} /> | |
</View> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment