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

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.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 6212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>