Skip to content

Conversation

@gaearon
Copy link
Collaborator

@gaearon gaearon commented Sep 18, 2019

Class components should never attempt to preserve state.

Normally this was already being handled by the Fresh Runtime. It chooses whether to put type in updatedFamilies (re-render) or staleFamilies (re-mount) based on whether it has .prototype && .prototype.isReactComponent. This is usually sufficient.

There are some corner cases where it isn't sufficient though. Such as recently deprecated factory components. They "look" like functions, but their fibers are tagged as a Class. I just spent an hour debugging a Fast Refresh issue in VR code which was caused by old Relay using factory components and hitting this.

While we don't want to support deprecated components, fixing this is easy and may also help with other corner cases we may encounter in the future. Like a second level of defense.

@sizebot
Copy link

sizebot commented Sep 18, 2019

No significant bundle size changes to report.

Generated by 🚫 dangerJS against fc8f23f

@gaearon gaearon merged commit f818af9 into facebook:master Sep 18, 2019
@gaearon gaearon deleted the fresh-fact branch September 18, 2019 15:45
gaearon added a commit to gaearon/react that referenced this pull request Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants