-
-
Notifications
You must be signed in to change notification settings - Fork 534
fix(index.js): Replaced the deprecated componentWillPeceiveProps
.
#487
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
Conversation
Thanks for the update! It's great to keep up with React. Unfortunately, you have some linting problems - you can run |
3dec51f
to
c07bc7b
Compare
@jackall3n My apologies for intruding on your PR but I believe you are replacing state with its own copy of state at every render call. Thanks for helping maintain the library, I'm hoping to use this in a new project |
@SNikon thanks, let me check it out :) |
83d2d9c
to
7e98332
Compare
As per the comment by @SNikon, I've updated the lifestyle method to return |
|
||
static getDerivedStateFromProps (nextProps, prevState) { | ||
const { ariaProps } = prevState | ||
const newAriaProps = parseAria(nextProps) | ||
const isChanged = Object.keys(newAriaProps).some(props => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not within the scope of this PR, but it seems like this check doesn't cover the case where newAriaProps
is a subset of the previous ariaProps
?
E.g.,
// prevProps
a = { a: 1, b: 2, c: 3 }
// new props
b = { a: 1, b: 2 }
// returns false, but `a` and `b` actually have different props
const isChanged = Object.keys(b).some(prop => b[prop] !== a[prop])
So maybe adding a length check would do?
E.g.,
const isChanged = Object.keys(newAriaProps).some(props => {
return newAriaProps[props] !== ariaProps[props]
}) && Object.keys(newAriaProps).length === Object.keys(ariaProps)
Now React 16.9.0 is released, which produces warnings about |
What's holding this from merging and releasing? Where do you need help? |
🎉 This PR is included in version 3.10.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
React has deprecated the use of componentWillReceivedProps, the static method
getDerivedStateFromProps should be used.