Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Restored mixin based implementation of observer for class based components #703

Merged
merged 9 commits into from
Jun 19, 2019

Conversation

mweststrate
Copy link
Member

@mweststrate mweststrate commented Jun 17, 2019

Proposal to revert to the classic implementation for class based observer components; by monkey patching the prototype rather than wrapping render in <Observer>

Fixes / affects #699, #692, #697, #702

@coveralls
Copy link

coveralls commented Jun 18, 2019

Coverage Status

Coverage increased (+1.08%) to 90.691% when pulling a4099e8 on revert-observer-class into 762e3d1 on master.

src/observerClass.js Outdated Show resolved Hide resolved
@mweststrate mweststrate mentioned this pull request Jun 18, 2019
@mweststrate mweststrate changed the title [WIP] Restored mixin based implementation of observer for class based components Restored mixin based implementation of observer for class based components Jun 18, 2019
@urugator
Copy link
Contributor

urugator commented Jun 18, 2019

Huh, haven't noticed that patching logic became so convoluted over time.
I know it's been mentioned many times that patching is necessary, but tbh I am not sure about specifics.
What's exactly problematic about extending the original component? Like:

class extends originalComponent {
  componentWillUnmount() {
    super.componentWillUnmount();
    // dispose 
  }
}

@mweststrate
Copy link
Member Author

mweststrate commented Jun 18, 2019 via email

Copy link
Contributor

@danielkcz danielkcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I am really surprised by how much hassle class support needs. Never paid much attention to it. Considering how easy is React.useEffect compared to disposeOnUnmount, people should be sprinting toward the hooks. Or running away from company that is slow on upgrades :D

src/observerClass.js Show resolved Hide resolved
@mweststrate mweststrate merged commit 9bd9cb5 into master Jun 19, 2019
@danielkcz danielkcz deleted the revert-observer-class branch June 19, 2019 09:32
@mweststrate
Copy link
Member Author

mweststrate commented Jun 19, 2019 via email

@urugator
Copy link
Contributor

Well technically there is a one already #645 :D

@mweststrate
Copy link
Member Author

mweststrate commented Jun 19, 2019 via email

@urugator
Copy link
Contributor

And I have another bad news ... this also affects disposeOnUnmount... actually @disposeOnUnmount is conceptually completely wrong, because constructors shouldn't contain side effects... all side effects should be in cDM or cDU.

@mweststrate
Copy link
Member Author

mweststrate commented Jun 19, 2019 via email

@github-actions github-actions bot mentioned this pull request Oct 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants