react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Semicolon's missing in a chapter of useState in React Docs(Beta).

Open mjjeon2645 opened this issue 2 years ago • 1 comments
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.

mjjeon2645 avatar Feb 24 '23 01:02 mjjeon2645

I think semicolons are avoided intentionally as semicolons are primarily optional in React.

vinaybadgujar102 avatar Feb 25 '23 10:02 vinaybadgujar102

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

rickhanlonii avatar Jan 10 '24 20:01 rickhanlonii