Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
SukkaW opened this issue Dec 11, 2023 · 1 comment
Closed

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

SukkaW opened this issue Dec 11, 2023 · 1 comment

Comments

@SukkaW
Copy link
Contributor

SukkaW commented Dec 11, 2023

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

@Rel1cx
Copy link
Owner

Rel1cx commented Dec 11, 2023

Looks good.

@Rel1cx Rel1cx changed the title [feat] prefer-use-state-lazy-initialization [Rule Request] react-hooks/prefer-use-state-lazy-initialization Dec 11, 2023
@Rel1cx Rel1cx closed this as completed in fa76901 Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants