-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
consider removing no-did-mount-set-state from recommended rules #596
Comments
I am agree with you, actually I'm doing exactly the same thing in some of my projects (render, measure, setState, re-render). But since it is pretty easy to do some accidental layout trashing without even realizing it I think it is better to keep this rule in the recommended ones, and use a |
It's absolutely necessary to do a @yannickcr Maybe it's time for a |
Well one could dispatch Redux actions and store layout info in Redux state, and it will be interesting to see if anyone comes up with a really slick fully-JS layout solution for React components, but when one just needs a few workarounds for the limitations of CSS layout, then component |
Of course that begs the question: eslint leaders wouldn't consider dispatching Redux actions in |
"Despatch a Redux action" is just a really elaborate way of setting state.
|
@yannickcr If you think |
@mjackson my point exactly |
@mjackson that's an interesting approach, even if I mostly agree with @ljharb about warnings #636 (comment). I'll be definitely interested if you have the time to craft a PR with this. |
Another point: async componentDidMount functions. |
@SirCmpwn I'm not sure about what you are referring to. Should not the |
That option seems to be designed for this case, but it doesn't work with async/await keywords from ES7. Example: async componentDidMount() {
const thing = await foobar();
this.setState({ thing });
} |
(nit: async/await is not in ES7, it's stage 3 and just a "future ES proposal") |
Nit sufficiently picked, still an issue :) |
Since there is some legitimate use cases to use |
Yes it leads to layout thrashing, but what else can you do when you need to perform a JS-computed layout? One can work around this by using DOM measuring wrapper components, but for components that do JS layout, setState() in componentDidMount() is a fairly common way of doing it.
The text was updated successfully, but these errors were encountered: