title: How to send data from next screen to previous screen and append data in an array in previous screen state variable in react native
body: <p>I have a situation where I want to send data from <strong>second screen</strong> to <strong>first screen</strong> class. Every time when I redirect from <strong>first screen</strong> to <strong>second screen</strong> and comeback from <strong>second screen</strong> to <strong>first screen</strong>, I want to pass data to Parent and append in an array in <strong>first screen</strong> class.</p>
  
  <p>first screen : </p>
  
  <pre><code>componentDidUpdate() {
      if (this.props.navigation.getParam('sizeData') != undefined) {
        if (this.props.navigation.getParam('sizeData') != this.state.sizeData) {
              let sizeDataArray = this.props.navigation.getParam('sizeData');
                this.setState({
                  sizeData: [...this.state.sizeData, sizeDataArray],
                )}
        }
      }
   }
  </code></pre>
  
  <p>second screen:</p>
  
  <pre><code>this.props.navigation.navigate('AddArticle', {
        sizeData: this.state.sizeData,
      });
  </code></pre>
  
  <p>In this situation when I try to append data, then componentDidUpdate creates an infinite loop. Can anyone provide some other method?</p>
  
  <p>Thanks in advance :)</p>