react.dev
react.dev copied to clipboard
"Rules of React" docs would cause TypeError
The example here would cause a TypeError: Assignment to constant variable.
https://github.com/reactjs/react.dev/blob/f055f8f3c2c9a8e5dbfe3a57e5a63b7769075abc/src/content/reference/rules/components-and-hooks-must-be-pure.md?plain=1#L236-L241
is it still valid... can i work on this?
is it still valid... can i work on this?
There's already a PR for this https://github.com/reactjs/react.dev/pull/6905
Okay... Thanks for letting me know
On Mon, 27 May 2024, 12:38 pm Reko Jokelainen, @.***> wrote:
is it still valid... can i work on this?
There's already a PR for this #6905 https://github.com/reactjs/react.dev/pull/6905
— Reply to this email directly, view it on GitHub https://github.com/reactjs/react.dev/issues/6903#issuecomment-2133293358, or unsubscribe https://github.com/notifications/unsubscribe-auth/APYOQHKRBI6GNKSCQ7ZHI2DZEMLNFAVCNFSM6AAAAABIE5LWFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZTGI4TGMZVHA . You are receiving this because you commented.Message ID: <reactjs/react. @.***>
If this issue was solved then close this issue.
The PR was not merged by the core team, so will rather keep this open. It should be automatically closed when the pull request is.
Can you tell me what the actual issue in this code? because I show there is no issue. ( Tell me how you get this issue. )
I found that code on the page and this code is written for the what kind of mistake cannot do in react state (Don’t mutate State ).
const [foo, bar] = [1, 2];
foo = foo + 1;
// Uncaught TypeError: Assignment to constant variable.
const Counter =()=> { const [count, setCount] = useState(0);
const handleClick =()=> setCount((prev)=>prev+1)
}