react.dev
react.dev copied to clipboard
Semicolon's missing in a chapter of useState in React Docs(Beta).
trafficstars
I think that a semicolon should be added an example of syntax of useState in the tutorial.
now
const [state, setState] = useState(initialState)
toBe
const [state, setState] = useState(initialState);
or is there any intention of removing semicolon? I just found that all examples are missing a semicolon in Beta version Docs.
Actually, examples of previous version documents have a semicolon, so.
I think semicolons are avoided intentionally as semicolons are primarily optional in React.
These are not meant to be runnable snippets of code, but and overview of the API definition.
This was actually fixed here: https://github.com/reactjs/react.dev/pull/5823 but I'm reverting it here: https://github.com/reactjs/react.dev/pull/6543