Open sys13 opened 1 month ago
Heya thanks for the suggestion @sys13!
const [_, setMyVar] = React.useState()
Is there a reason you don't want to do const [, setMyVar] = React.useState()
?
Also: I'm under the impression it's a bit of an antipattern / discouraged to set up state like this. Most React practices I've seen have encouraged keeping to simple state primitives and not relying on API details like "there's a rerender if I update this never-used state". Is there a reproduction case you can post for why you'd really want this?
The other cases apply to
(myVar, ...rest) => ...
andfunction(_, stuff)
which is useful when composing functions.
Similar question here. My general impression has been that having to declare unused parameters is a symptom of confusing code styles. I worry that this is not a particularly common need - so might not make sense as the default in a general-purpose create-*-app
?
Bug Report Checklist
main
branch of the repository.Overview
I would suggest the following changes:
This can help in the common React case of
const [_, setMyVar] = React.useState()
where you want to do array restructuring but don't want to keep the first argument. The other cases apply to(myVar, ...rest) => ...
andfunction(_, stuff)
which is useful when composing functions.Additional Info
No response