title: React JS: Passing values when back button is clicked
body: <p>I am creating a website using React JS to allow users to click on a brand and scrape images from Instagram. On the landing page <strong>/landing</strong>, the user can select a brand and this brand name is passed to the Instagram scraper page <strong>/instagramScraper</strong>:</p>
  
  <pre><code>    this.props.history.push({
        pathname: '/instagramScraper',
        params: {
          brandName: this.state.brand_name
        }
      });
  </code></pre>
  
  <p>The instagram scraper page gets the brandName using the following code:</p>
  
  <pre><code>this.state.brandName = props.location.params["brandName"];
  </code></pre>
  
  <p>The user is now able to click on an image on this <strong>/instagramScraper</strong> and is brought to another page <strong>/editPhoto</strong> where the image can be edited. After selecting the "back button" from <strong>/editPhoto</strong>, I get this error:</p>
  
  <pre><code>TypeError: Cannot read property 'brandName' of undefined new Landing
  
  src/components/instagramScraper.js:24
    21 |   this.onAddImages = this.onAddImages.bind(this);
    22 |   this.onScrape = this.onScrape.bind(this);
    23 |   this.learnMore = this.learnMore.bind(this);
  &gt; 24 |   this.state.brandName = props.location.params["brandName"];
  </code></pre>
  
  <p>How can I pass in the brandName param when the back button is selected from the photoEdit page? I have tried using this.setState in the landing page, however the value of the brandName gets reset.</p>