Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

ComponentWillReceiveProps calling multiple time using react native

$
0
0

In my scenario, I am trying to change the switch value on real time. Here, whenever the switch index value on/off changing componentWillReceiveProps calling twice at a time. How to solve this issue?

My Code Below

componentWillReceiveProps(nextProps) {    switch (this.state.selectedIndex) {      case 0:        if (nextProps.checkState.reported.on) {          this.setState({ switchValue: true });        } else {          this.setState({ switchValue: false });        }        break;      default:        this.setState({ switchValue: nextProps.checkState.on });    }  }

Viewing all articles
Browse latest Browse all 16750

Trending Articles