Skip to content

RadioGroup - Replace unsafe method with getDerivedStateFromProps #932

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

Merged
merged 1 commit into from
Sep 15, 2020

Conversation

mendyEdri
Copy link
Contributor

Using now getDerivedStateFromProps instead of UNSAFE_componentWillReceiveProps

const {value} = prevState;
const {initialValue} = nextProps;

if (_.isUndefined(nextProps.initialValue) || value === initialValue) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why no turn the component to uncontrolled component? Where the initialValue is literally initial value and not updated through a prop change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Inbal-Tish, Yeah, I though about it, but then we going to lose the use case to let users 'reset' the component value.
I consult with Ethan to have a second opinion and we said that this use-cases should be kept

@Inbal-Tish Inbal-Tish changed the title Replace unsafe method with getDerivedStateFromProps RadioGroup - Replace unsafe method with getDerivedStateFromProps Sep 15, 2020
@Inbal-Tish Inbal-Tish merged commit b7bfe5e into master Sep 15, 2020
@mendyEdri mendyEdri deleted the infra/radio-group-remove-unsafe branch September 15, 2020 14:46
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.

2 participants