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

Update state.text if props.children change. #9

Closed
wants to merge 5 commits into from

Conversation

createthis
Copy link
Contributor

Fix for #8 including test reproducing the problem.

Copy link
Owner

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

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

Thanks @createthis 👍

src/index.js Outdated
@@ -34,6 +34,11 @@ class EllipisWithTooltip extends React.Component {
}
}

componentWillReceiveProps(nextProps) {
if (nextProps.children === this.props.children) return;
Copy link
Owner

Choose a reason for hiding this comment

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

it compares the references. if the values are the same do we need to update the state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and how do you recommend doing a value comparison here? Deep object comparison would potentially be inefficient.

src/index.js Outdated
@@ -34,6 +34,11 @@ class EllipisWithTooltip extends React.Component {
}
}

componentWillReceiveProps(nextProps) {
Copy link
Owner

@amirfefer amirfefer Aug 26, 2019

Choose a reason for hiding this comment

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

componentWillReceiveProps is deprecated, how about using getDerivedStateFromProps or componentDidUpdate, instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I noticed that. I'll try getDerivedStateFromProps. I'll try to get to this tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amirfefer it looks like react-ellipsis-with-tooltip depends on react 15 or 16. getDerivedStateFromProps isn't introduced until 16.3. How do you want to handle that?

Copy link
Owner

Choose a reason for hiding this comment

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

I've added support for react 16.3 :)
would you mind to rebase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amirfefer synced with upstream and updated to use getDerivedStateFromProps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm. node 12 test failing. investigating.

license Outdated
@@ -1,9 +0,0 @@
MIT License
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two of these. Uppercase LICENSE and lowercase license. Thought I would keep the uppercase, but I can bring it back if this was the wrong choice.

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

2 participants