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

"Rules of React" docs would cause TypeError

Open reko-lygg opened this issue 1 year ago • 8 comments
trafficstars

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

reko-lygg avatar May 23 '24 05:05 reko-lygg

is it still valid... can i work on this?

ijayhub avatar May 25 '24 20:05 ijayhub

is it still valid... can i work on this?

There's already a PR for this https://github.com/reactjs/react.dev/pull/6905

reko-lygg avatar May 27 '24 11:05 reko-lygg

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. @.***>

ijayhub avatar May 27 '24 13:05 ijayhub

If this issue was solved then close this issue.

ParthVirgoz avatar Sep 09 '24 09:09 ParthVirgoz

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.

reko-lygg avatar Sep 09 '24 10:09 reko-lygg

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 ).

ParthVirgoz avatar Sep 11 '24 13:09 ParthVirgoz

const [foo, bar] = [1, 2];
foo = foo + 1;
// Uncaught TypeError: Assignment to constant variable.

reko-lygg avatar Sep 12 '24 10:09 reko-lygg

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

const handleClick =()=> setCount((prev)=>prev+1)

}

devtunis avatar Sep 12 '24 11:09 devtunis