Skip to content

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

2 participants