Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Class components should not subscribe to state changes in the constructor. #103

Open
quisido opened this issue Jul 1, 2019 · 0 comments
Labels
help wanted The owner cannot resolve this on their own.
Milestone

Comments

@quisido
Copy link
Collaborator

quisido commented Jul 1, 2019

If a component has be instantiated (constructor has executed) but not yet mounted, this.updater will be undefined. If the global state is accessed in the constructor, it will subscribe. If it changes before mount, it will attempt to update, throwing an error that this.updater does not exist.

Either check that this.updater exists or prevent subscribing in the constructor (if possible to differentiate).

@quisido quisido added the bug Something isn't working as expected. label Jul 1, 2019
@quisido quisido added this to the 2.1.5 milestone Jul 1, 2019
@quisido quisido self-assigned this Jul 1, 2019
@quisido quisido modified the milestones: 2.1.5, 2.1.6 Jul 21, 2019
@quisido quisido modified the milestones: 2.1.6, 2.1.8 Aug 8, 2019
@quisido quisido removed their assignment Sep 5, 2019
@quisido quisido added help wanted The owner cannot resolve this on their own. and removed bug Something isn't working as expected. labels Nov 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted The owner cannot resolve this on their own.
Projects
None yet
Development

No branches or pull requests

1 participant