Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix elementParentNode class list re-render issue in 1.x #216

Merged
merged 11 commits into from Oct 26, 2019

Conversation

j3tan
Copy link
Contributor

@j3tan j3tan commented Oct 17, 2019

Fixing re-render issue caused by a too-simplistic className check. The tether library adds its own classes to the tether parent node so it always mismatches the prop value

fixes #201

@@ -94,6 +94,20 @@ class TetherComponent extends Component {
if (this._targetComponent && this._elementComponent) {
this._createContainer();
}

// Verify if className props have changed
if (this._elementParentNode && this.props.className !== props.className) {
Copy link
Contributor Author

@j3tan j3tan Oct 17, 2019

Choose a reason for hiding this comment

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

Copied over from the other commit in (#211)

This is in the componentWillUpdate to avoid refactoring _update() and closely mimics the other PR even though that one uses componentDidUpdate.

@j3tan
Copy link
Contributor Author

j3tan commented Oct 25, 2019

strange, the component test passed before and still does locally

@danreeves
Copy link
Owner

Yeah, really strange. I'm not sure what's up

@j3tan
Copy link
Contributor Author

j3tan commented Oct 25, 2019

I think something with the package lock caused the issue, may need to revert that completely

Edit: this was not the issue

@j3tan
Copy link
Contributor Author

j3tan commented Oct 25, 2019

oh i know, its the enzyme issue with react-test-renderer caused by the UNSAFE_ change - the CI test suite uses enzyme-adapter-react-install 15.5 which doesn't support it.

It should have been caught here: #215

Basically the UNSAFE_ change is a major breaking change that causes react-tether@1.x to stop working for React 15. Unfortunately, we're in this weird place between majors but trying to patch something specifically for React 16. It may even be worth it to fork the repo into something like react-tether-legacy,react-tether-for-react-16, or some alternative?

@react-tether-bot
Copy link

react-tether-bot commented Oct 25, 2019

Messages
📖 🤔 Hmmm, code coverage is looking low for the whole codebase.
📖 🎉 Thanks for working on tests!
📖 Hey @j3tan, thanks for submitting a pull request! 😸

Coverage in All Files

File Line Coverage Statement Coverage Function Coverage Branch Coverage
src/react-tether.js (0/0) 100% (0/0) 100% (0/0) 100% (0/0) 100%
src/TetherComponent.jsx (85/96) 89% (85/96) 89% (21/27) 78% (59/67) 88%
Total (85/96) 89% (85/96) 89% (21/27) 78% (59/67) 88%

Generated by 🚫 dangerJS

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.5%) to 83.117% when pulling 3501344 on j3tan:1.x-patch-rerender into c9ad68c on danreeves:1.x.

@j3tan
Copy link
Contributor Author

j3tan commented Oct 25, 2019

Yep, short of forking the repo, we may want to publish these changes as a 1.1.0 and add some sort of documentation to README on master on resolving issues with React 15 and React 16.0-16.2 (i.e. using a fixed version of react-tether instead of a ^.

thanks for taking the time to merge these changes though, will definitely help us clean up all those warnings we are getting

@danreeves
Copy link
Owner

@j3tan I think I'm happy with this last change. Thoughts? I really don't want to break compatibility

@j3tan
Copy link
Contributor Author

j3tan commented Oct 25, 2019

Fix looks good to me. ship it!

@@ -286,4 +291,18 @@ class TetherComponent extends Component {
}
}

function componentWillUpdate(nextProps) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wish we could use componentDidUpdate but I don't think it's viable for React 15.x due to the way it'll render. We may want to test it, but I think this solution works for now

@danreeves danreeves merged commit c9afffb into danreeves:1.x Oct 26, 2019
@mattcrowder
Copy link

Do you plan on publishing a minor version?

@danreeves
Copy link
Owner

Published in 1.0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants