Skip to main content

Command Palette

Search for a command to run...

React Hook - useState()

Updated
1 min readView as Markdown
React Hook  - useState()

This is a javascript syntax , which is called " Array Destructuring " and we use it because useState always returns an array with exactly two elements. And with this syntax, we are pulling these elements out of that returned array. And we store them in separate constant of the name enteredUsername and setEnteredUsername.

const [enteredUsername, setEnteredUsername] = useState(' ');

More from this blog

Omar's blog

135 posts