0

This doubt comes from React Hooks Tutorial and it's particulary strange for me:

const [count, setCount] = useState(0);

The order is important when declaring? What name receives this sort of declaration? Since what version of ES this syntax was launched?

Cesar Jr Rodriguez
  • 1,244
  • 3
  • 17
  • 26
  • Here's another similar question with a useful answer: https://stackoverflow.com/questions/26999820/javascript-object-bracket-notation-navigation-on-left-side-of-assign – Cat Feb 05 '19 at 19:48

1 Answers1

1

That's array destructuring. useState returns an array with three values, count will then get the value of the first array entry, setCount of the second and so on.

Jonas Wilms
  • 106,571
  • 13
  • 98
  • 120