Skip to content

Allow nested destructuring with react/hook-use-state #3443

Closed
@philer-jambit

Description

@philer-jambit

State is not always flat and sometimes it can make sense to destructure it directly. Example:

const [{foo, bar, baz}, setFooBarBaz] = useState({foo: "omg", bar: "wtf", baz: "bbq"})
const [[index, value], setValueWithIndex] = useState([0, "hello"])

Note that in these cases the setter name can not be symmetrical to the destructured variables.

It would be nice if react/hook-use-state permitted this use case (maybe optional?).

Either way, thanks for the great work! 👍

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions