title: Is React context provider not mounted before child components?
body: <p>How do I make sure I set a value in the context provider before components are mounted?</p>
  
  <p>In the code example below, the console.log in the child component(Dashboard) will be logged first (as undefined). Why is that and is there any way for me to make sure the value is set before that component is mounted?</p>
  
  <p><strong>App.js</strong></p>
  
  <pre><code>render() {
    return (
      &lt;div className='App'&gt;
        &lt;ContextProvider&gt;
          &lt;Dashboard /&gt;
        &lt;/ContextProvider&gt;
      &lt;/div&gt;
    );
  }
  </code></pre>
  
  <p><strong>ContextProvider.js</strong></p>
  
  <pre><code>componentDidMount = () =&gt; {
    this.setState({value: 1})
    console.log(this.state.value);
  }
  </code></pre>
  
  <p><strong>Dashboard.js</strong></p>
  
  <pre><code>componentDidMount = () =&gt; {
    console.log(this.context.value);
  }
  
  </code></pre>