Created
June 12, 2020 22:21
-
-
Save ltsharma/d5152ca1378fed90e651c5fca811b5cc 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
export default ()=>{ | |
//Sates is 0 initially | |
const [pressCount, setPressCount] = useState(0); | |
//Function to update last state by +1 | |
const updateButtonPress = useCallback(() => { | |
setPressCount(pressCount + 1); | |
}, []); | |
//Empty dependancy | |
return( | |
<Button onPress={updateButtonPress} title="Add 1" /> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment