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

Remove call to componentWillReceiveProps #164

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/AutosizeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ class AutosizeInput extends Component {
this.copyInputStyles();
this.updateInputWidth();
}
componentWillReceiveProps (nextProps) {
const { id } = nextProps;
componentDidUpdate (prevProps, prevState) {
const { id } = prevProps;
if (id !== this.props.id) {
this.setState({ inputId: id || generateId() });
this.setState({ inputId: this.props.id || generateId() });

Choose a reason for hiding this comment

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

More correct to use getDerivedStateFromProps for update state based on props

Choose a reason for hiding this comment

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

Performance difference is despicable. Can't we move ahead and approve the PR? Using this deprecated event is much worse than this detail

}
}
componentDidUpdate (prevProps, prevState) {
if (prevState.inputWidth !== this.state.inputWidth) {
if (typeof this.props.onAutosize === 'function') {
this.props.onAutosize(this.state.inputWidth);
Expand Down