title: Warning: Can't perform a React state update on an unmounted component....componentWillUnmount method
body: <p>I'm very new to <strong>React</strong> and <strong>React Native</strong> and I am getting this warning when I switch screens. Also, the <code>console.log</code> keeps repeating infinitely, how do I fix it?</p>
  
  <pre><code>class DecodeScreen extends Component {
    state = {
      data: this.props.navigation.getParam("data", "NO-QR"),
      bookData: '',
      bookFound: false
   }
  
   bookSearch = () =&gt; {
        query = `https://librarydb-19b20.firebaseio.com/books/${this.state.data}.json`,
        axios.get(query)
             .then((response) =&gt; {
                 const data = response.data ? response.data : false
                     console.log(data)
                     if (data) {
                      this.setState({
                          bookData: data,
                          bookFound: true
                      })
                  }
              }).catch((error) =&gt; {
  
                  this.setState({
                      bookFound: false
                  })
              })
    }
    renderContent = () =&gt; {
      if (this.state.bookFound) {
          return( 
            &lt;View&gt;
            &lt;TextH5&gt;{this.state.bookData.title}&lt;/TextH5&gt;
            &lt;TextH5&gt;{this.state.bookData.author}&lt;/TextH5&gt;
            &lt;TextH5&gt;{this.state.bookData.publisher}&lt;/TextH5&gt;
            &lt;TextH5&gt;{this.state.bookData.isbn}&lt;/TextH5&gt;
            &lt;/View&gt;
          )
        }
        else {
          return &lt;TextH5&gt;beer not found&lt;/TextH5&gt;
        } 
  }
  componentDidMount() {
    this.bookSearch()
  }
  
    render() {
      {this.bookSearch()}
    return (
      &lt;Container&gt;
        &lt;TextH5&gt;{this.state.data}&lt;/TextH5&gt;
        {this.renderContent()}
      &lt;/Container&gt;
    );
    }}
  export default DecodeScreen;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5b8At.jpg" rel="nofollow noreferrer">the console.log output</a><a href="https://i.stack.imgur.com/1wdxY.jpg" rel="nofollow noreferrer">the warning</a></p>