eslint-plugin-react icon indicating copy to clipboard operation
eslint-plugin-react copied to clipboard

Supporting async/await in `no-did-mount-setstate` rule

Open idanen opened this issue 7 years ago • 4 comments

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.

idanen avatar Sep 25 '18 12:09 idanen

Sure. Do you have some in mind?

idanen avatar Sep 25 '18 14:09 idanen

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.

ljharb avatar Sep 25 '18 14:09 ljharb

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

idanen avatar Oct 08 '18 07:10 idanen

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 avatar Oct 09 '18 16:10 ljharb