|
|
|
|
|
by IceMetalPunk
1384 days ago
|
|
When you have something like `const [variable, setVariable] = setState('foobar')`, you are not getting "variable" back directly. Instead, you're getting a pair of a setter function and a getter function. React keeps track of the variable's value internally, and when you access `variable` you're really just calling a getter function that "requests" the value from React, essentially. So you can can call `setVariable` to modify the value internally to React without actually changing the binding of the variable you see, hence it can be const. |
|