title: React Native Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state
body: <p>Im learning react native, and i try to use state, now im facing an issue &quot;Cannot update during an existing state transition (such as within <code>render</code>). Render methods should be a pure function of props and state.&quot;
  Here my code</p>
  <pre><code>class Quantity extends React.Component {
  
    constructor(props) {
      super(props);
      this.state = {
        qty:1
      };
      this.setQty = this.setQty.bind(this);
    }
    setQty = (e) =&gt;{
      this.setState({
        qty:e,
      });
    }
    
    componentDidMount() {
      this.props.onRef(this)
      this.state.qty = 1
    }
    componentWillUnmount() {
      this.props.onRef(undefined)
    }
  
    getCheckoutQty() {
      return this.state.qty.toString();
    }
  
    minusQty = () =&gt; {
      let newQty = this.state.qty -1;
      this.setQty(newQty)
    }
  
  
  
    plusQty = () =&gt; {
      let newQty = this.state.qty +1;
      this.setQty(newQty);
    }
  
  
    render() {
      const {qty}=this.state
      return (
        &lt;View style={styles.row}&gt;
          &lt;TouchableOpacity style={styles.icon}
            disabled={(this.state.qty==1)?true:false}
            // onPress={() =&gt; this.minusQty()}
          &gt;
            &lt;Icon name=&quot;minus&quot; color=&quot;#000&quot; style={(this.state.qty==1)?{opacity:0.2}:{opacity:1}}/&gt;
          &lt;/TouchableOpacity&gt;
          &lt;Input
            style={styles.qtyBox}
            keyboardType=&quot;numeric&quot;
            returnKeyType=&quot;done&quot;
            value={qty.toString()}
            onChangeText={(e)=&gt;this.setQty(this)} 
          /&gt;
          &lt;TouchableOpacity style={styles.icon}
            // onPress={() =&gt; this.plusQty()}
          &gt;
            &lt;Icon name=&quot;plus&quot; color=&quot;#000&quot; /&gt;
          &lt;/TouchableOpacity&gt;
        &lt;/View&gt;
      );
    }
  
  }
  </code></pre>
  <p>any way to fix it?
  Thank for the support</p>