-
-
Save aiuoe/95e5440ea5e2db184e62e99aff406854 to your computer and use it in GitHub Desktop.
JS vanilla hook useState
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 useState = (initValue) => { | |
const state = { value: initValue }; | |
const setState = (updatedValue) => state.value = updatedValue; | |
return [state, setState]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment