I m building an appointment application with react native,its my first try in RC,Using react-redux to manage the state.I need some clarification about lifecycle methods.
Details.js
class Details extends Component {
constructor(props) {
super(props);
}
componentDidMount(){
this.props.bookingAndSuggestions(Data)
}
componentWillReceiveProps(nextProps){
if( Object.keys(nextProps.bookingSuggestionStatus).length >0) {
if(nextProps.bookingSuggestionStatus.res.data.status=='available') {
this.setState({isAvailable:false})
} else {
this.setState({isAvailable:true})
}} }
onBookNow=()=>{
this.props.shops(Data);
}
Here is the deal,Initially i call react-redux action prop this.props.bookingAndSuggestions(Data)
and i capture the response inside componentWillReceiveProps
,and On booking this.props.shops(Data);
will trigger and it also updates the componentWillrecieveprops
,the logic inside the componentwillrecieveprops updates each time when props changes.What is the proper approach to deal with such situation?