title: how do i pass data between views in react js
body: <p>I have two views. One is a left nav that has a list of items the other is the main screen that I need to change depending on which item you select.</p>
  
  <p>here is the toggle function that I change the "name" I'm trying to update</p>
  
  <pre><code>onToggleFilter(checked) {
      let d = this.props.data
      this.setProjectName(d.id)
      //console.log("name" + d.id)
      d.onFilter = checked
      if( d.children &amp;&amp; d.children.length &gt; 0 ) {
          d.children.forEach( item =&gt; {
              item.onFilter = checked
          })
      }
      this.setState({ selected: checked })
      if( this.props.onFilterChanged ) {
          this.props.onFilterChanged(checked)     
      }
  }
  
  setProjectName (data){
      console.log ("name" + data)
      let projectName = data
  
  }
  </code></pre>
  
  <p>that consoles out to name Remarkable (thats one of the projects on the left nav)</p>
  
  <p>Somehow I need to pass that projectName to another component. I'm new to react and I'm sure its something simple but from reading the documentation I'm a little stuck.</p>
  
  <p>OK I think I know how to do the first part:</p>
  
  <p>I have a data service file that has this function</p>
  
  <pre><code>getNavInfo (){
  
  
          _instance.navData = navArray
  
          console.log ("instance hit"+ navArray)
  
      }
  </code></pre>
  
  <p>This picks up on an array of items that is set elsewhere in the file</p>
  
  <p>Here is the call on the other component</p>
  
  <pre><code>getDataNav ()
  
      {
          let d = this.dataService.getNavInfo()
          console.log ("d here" + d)
      }
  </code></pre>
  
  <p>Dataservice is the other component.</p>
  
  <p>When I do this though</p>
  
  <pre><code>this.dataService.getNavInfo().then(this.getDataNav)
  
  getDataNav (data)
  
      {
              console.log ("d here" + data);
      }
  </code></pre>
  
  <p>Its telling me that this is undefined  - </p>
  
  <pre><code>this.dataService.getNavInfo().then(this.getDataNav)
  </code></pre>