-
Notifications
You must be signed in to change notification settings - Fork 141
Introduce much more detailed setState error messages #67
Conversation
lib/invalidSetStateMessages.lua
Outdated
Check the component %q to see if: | ||
* setState could be called by a child Ref | ||
* setState could be called by a child Changed event | ||
* setState could be called by a child's render method]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but might be clearer to say "setState is being called by...". Otherwise, it kind of sounds like a suggestion rather than a possible diagnosis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll probably also fold that part into the section before the list, like:
Check the component %q to see if setState is being called by:
- a child Ref
- a child Changed event
- a child's render method
Check the definition of shouldUpdate in the component %q.]] | ||
|
||
invalidSetStateMessages["init"] = [[ | ||
setState cannot be used in the init method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to mention that you can set state
directly in init
.
All of the messages are updated. Any other feedback? |
Nah, LGTM! |
LGTM as well |
Fixes #66.
This PR replaces the single "you can't use setState here" message with a bunch of new messages, each tailored to the exact case.
They give much more useful information, and where possible, where to put your
setState
call instead.It also catches an extra case where the render and reconciliation steps were not being guarded, specifically during reify.