title: How to use react context api with getDerivedStateFromProps?
body: <p>Context provides a way to pass data through the component tree without having to pass props down manually at every level. This is great!</p>
  
  <p>but I'm wondering how to use it with getDerivedFromProps()</p>
  
  <p>For example, if I have a prop sent via Context in top level of the app, that said it's <code>window.location.href</code>, and I need to take action in the child component based on the href, e.g. fetch the data.</p>
  
  <p>Using getDerivedStateFromProps(), I have to write something like the following:</p>
  
  <pre><code>getDerivedStateFromProps(nextProps, state) {
  
    var stateRev = null
    var pathname = hrefToPath(nextProps.href)
    if (pathname != state.pathname) {
      stateRev = {}
      Object.assign(stateRev, {
        pathname,
        book: source.find()
      })
    }
    return stateRev
  }
  </code></pre>
  
  <p>However, if I write the code like the above, I have to send the window.location.href through the levels. What I need to know is if the prop in the context changed, I need to update the state.</p>
  
  <p>I see no way to know the prop in the context changed or not. Is there anything I need to know about the context api and getDerivedStateFromProps?</p>
  
  <p>Thank you.</p>