title: Passing state to preact component
body: <p>I have a newcomer to react/preact. I have a simple app that fetches weather forecast from an API and I want this data to be passed to a chart component (precharts). The problem I have is when this chart gets rendered, the data has not yet been fetched and I get type errors, because I am already trying to process it. I saw another question where the top answer suggested to conditionally assign null instead of the component to a variable when my parent component's state is not yet evaluated.</p>
  
  <p>In the parent component, I have the following method that sets the state to be passed (it is called by the parent's constructor):</p>
  
  <pre><code>parseHourly = (parsed_json) =&gt; {
      for (let i = 0; i &lt; 7; i++) {
          var h = parsed_json['hourly_forecast'][i]['FCTTIME']['hour'];
          var t = parsed_json['hourly_forecast'][i]['temp']['metric'];
          var pair = {hour: h, temperature: t};
          this.state.temps.push(pair);
      }
  }
  </code></pre>
  
  <p>This is the parent's render method where I create the chart:</p>
  
  <pre><code>render() {
      let myChart;
      if(this.state.temps) {
          myChart = &lt;Chart temps={this.state.temps}/&gt;
      } else {
          myChart = null
      }
  
      return (
          &lt;div class={ style.container }&gt;
              ...
              { myChart }
              ...
          &lt;/div&gt;
      );
  }
  </code></pre>
  
  <p>In the Chart component, I'm trying to access <code>this.props.temps</code> directly in the <code>render()</code> method, but I end up with the value being <code>undefined</code>.
  What am I doing wrong? Help much appreciated.</p>