▲ | snemvalts 3 hours ago | |
You can write const [a, b] = useState('x') in vanilla js and typescript. Hence it is not magic syntax. | ||
▲ | rictic 10 minutes ago | parent [-] | |
Yeah, that's vanilla syntax. The semantics are fairly magic though. The component function that calls useState though isn't a normal function, it's a function that must be called in a special way by the React runtime in order to line up all of the hidden state that React maintains so that it can magically infer the data that your `useState` call maps to and then there's more magic to maintain the lifetime of that data. |