0

This is a very detailed question but im wondering...

let [state, updateState] = useState()

that piece of code returns an initial state, but when we use updateState, how does react actually go into our code and change that "state" ,which is an already updated value? How do they have access to our code to change it like that?

1 Answers1

-1

Initial state is stored in [useState("INITIAL-STATE_VALUE")]. and This statement takes toe parameter's first one is the name of state and the second one is the function which update the state when you call it. So whenever you called that function that will update your state according to you..