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

refactor: prevent usage of this.state inside setState calls #2302

Draft
wants to merge 1 commit into
base: alpha
Choose a base branch
from

Conversation

damianstasik
Copy link
Contributor

New Pull Request Checklist

Issue Description

This PR enables ESLint react/no-access-state-in-setstate rule that disallows access of this.state within setState calls. This can prevent nasty bugs caused by referencing old state, unfortunately while refactoring the code I spotted multiple direct this.state manipulations which should be also refactored as soon as possible to avoid unexpected behavior caused by for example concurrent rendering in React 18.

Related issue: #1950

Approach

TODOs before merging

  • Add tests
  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • A changelog entry is created automatically using the pull request title (do not manually add a changelog entry)

@parse-github-assistant
Copy link

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant