You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
As @GroovinChip pointed out in one of a twitter thread, calling setState from a widget initState or build methods will lead to unnecessary rerender of the widget. It looks like a potential problem especially for new developers, so the idea of the rule is to warn about setState invocations in initState or build.
We have not quite come to a conclusion, should we also consider calling sync methods from a widget initState with setState call in it bad or acceptable.
@GroovinChip thanks again for providing examples and sharing the idea.
@GroovinChip if you have some time to review the proposal, I'd be very grateful.
@dkrutskikh@roman-petrov I'd really happy to hear your thoughts about this rule and maybe you know some other places where calling setState should be considered unnecessary.
I'm not quite sure how this rule should be called, right now we have 3 options:
avoid-unnecessary-setstate
avoid-additional-render
avoid-rerender
If you have any opinion on that, I'd like to hear it as well.
Also, if you know anyone, who can add some thoughts on this rule, please invite them to the discussion.
Please describe what the rule should do:
As @GroovinChip pointed out in one of a twitter thread, calling
setState
from a widgetinitState
orbuild
methods will lead to unnecessary rerender of the widget. It looks like a potential problem especially for new developers, so the idea of the rule is to warn aboutsetState
invocations ininitState
orbuild
.We have not quite come to a conclusion, should we also consider calling sync methods from a widget
initState
withsetState
call in it bad or acceptable.@GroovinChip thanks again for providing examples and sharing the idea.
Additional resources:
What category of rule is this? (place an "X" next to just one item)
[X] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about (it will be better if you can provide both good and bad examples):
Bad:
The text was updated successfully, but these errors were encountered: