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

Feature Request: ESLint hooks rule for accessing previous state when deriving new state #30363

Open
Samuel-Therrien-Beslogic opened this issue Jul 17, 2024 · 2 comments
Labels
Component: ESLint Rules Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@Samuel-Therrien-Beslogic

#21448

A very common mistake and source of bugs in React applications is not using the updater function when deriving new state from old state.

When using class components, there is a handy lint rule for this in the eslint-plugin-react project.

However, their rule does not work for functional components that utilize useState, and they have suggested that eslint-plugin-react-hooks would be a more appropriate home for an equivalent lint rule that does work with hooks.

I've seen this mistake made countless times, and I even fall victim to it every once in awhile, so having an officially sanctioned lint rule would be amazing!

Conversation was locked so we couldn't bump the issue. Note that I'd prefer that issue be re-opened and this one here closed to keep participants, followers, upvotes, creation date, etc.

CC @martdavidson @palfrey @johncmunson, @dangerismycat, @mathieutu, @vlnguyen, @aldenquimby, @schyler-freewill, @Stephen2

@eps1lon eps1lon added Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Component: ESLint Rules and removed React 19 labels Jul 22, 2024
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@github-actions github-actions bot added Resolution: Stale Automatically closed due to inactivity and removed Resolution: Stale Automatically closed due to inactivity labels Oct 20, 2024
@Samuel-Therrien-Beslogic
Copy link
Author

Bump, and I'd still prefer the old issue be re-openned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ESLint Rules Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

4 participants
@eps1lon @Samuel-Therrien-Beslogic and others