Skip to content

[Rule Request] react-hooks/prefer-use-state-lazy-initialization #214

@SukkaW

Description

@SukkaW
Contributor

Describe the problem

Disallow function calls in useState that aren't wrapped in an initializer function:

// Bad
const [value, setValue] = useState(generateTodos());
// Good
const [value, setValue] = useState(() => generateTodos());

Describe the solution you'd like

Port jsx-eslint/eslint-plugin-react#3579

Alternatives considered

No response

Additional context

No response

Activity

Rel1cx

Rel1cx commented on Dec 11, 2023

@Rel1cx
Owner

Looks good.

changed the title [-][feat] `prefer-use-state-lazy-initialization`[/-] [+][Rule Request] `react-hooks/prefer-use-state-lazy-initialization`[/+] on Dec 11, 2023
added a commit that references this issue on Apr 15, 2024
fa76901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Rel1cx@SukkaW

        Issue actions

          [Rule Request] `react-hooks/prefer-use-state-lazy-initialization` · Issue #214 · Rel1cx/eslint-react