Skip to content

Instantly share code, notes, and snippets.

@ArfatSalman
Created March 13, 2018 13:47
Show Gist options
  • Save ArfatSalman/cbd63428a304f99acfc986237abcd80b to your computer and use it in GitHub Desktop.
Save ArfatSalman/cbd63428a304f99acfc986237abcd80b to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
class MyComponent extends Component {
constructor(props){
super(props);
this.state = {
someValue: props.someValue,
};
}
componentWillReceiveProps(nextProps){
if (nextProps.inputValue !== this.props.inputValue) {
this.setState({ inputVal: nextProps.inputValue })
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment