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

Supporting async/await in no-did-mount-setstate rule #1996

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

Conversation

idanen
Copy link

@idanen idanen commented Sep 25, 2018

Pretty naive approach: checking if the call is in an async method and if an await is found before setState (going over tokens).

Fixes #1110.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a great start, but I think it'd need lots more test cases.

@ljharb ljharb changed the title Supporting async/await in no-did-mount-setstate rule (fixes #1110) Supporting async/await in no-did-mount-setstate rule Sep 25, 2018
@idanen
Copy link
Author

idanen commented Sep 25, 2018

Sure. Do you have some in mind?

@ljharb
Copy link
Member

ljharb commented Sep 25, 2018

Things mentioned in the linked issue; this.setState defined in a callback function before the first await, but not invoked or passed to anything prior to the first await; things like that.

@idanen
Copy link
Author

idanen commented Oct 8, 2018

That's much more difficult...
Do you think we should use a different "entry" than what is currently used for this rule?
I don't really have any experience or knowledge in AST so I think I'll need some help to continue

@ljharb
Copy link
Member

ljharb commented Oct 9, 2018

I feel like we may have to track all awaits inside cDM, as well as all this.setState calls, and after they’re all tracked, figure out which ones are a problem.

It’s certainly a very hard problem.

@ljharb ljharb marked this pull request as draft October 15, 2020 17:58
@ljharb ljharb force-pushed the master branch 6 times, most recently from 59af733 to 865ed16 Compare November 11, 2022 02:45
@ljharb ljharb force-pushed the master branch 4 times, most recently from 069314a to 181c68f Compare November 18, 2022 17:19
@ljharb ljharb force-pushed the master branch 2 times, most recently from 380e32c to 51d342b Compare July 4, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Should react/no-did-mount-set-state trigger on ES2017 async componentDidMount?
2 participants