title: React userReducer init function not triggering on props update
body: <p>I have a component which is a form which I use to create records in my database. I also want to be able to pass into this component values with which to populate the form, allowing me to then update my existing database records. Straightforward add/edit functionality from the same component.</p>
  
  <p>The following code should explain how I am doing this. The <code>media</code> prop is an object containing the data. I have this data already in the parent element so setting the values here is fine and they pass thru without problem. However once the page is loaded the 3rd <code>init</code> argument of <code>useReducer</code> never re-triggers, and therefore my state cannot be overridden with the values passed down in the <code>media</code> prop. Is there a correct way to make the <code>init</code> function trigger when the props are updated, or is my issue architectural?</p>
  
  <pre><code>const MediaUploadForm = ({ media }) =&gt; {
  
    const init = (initialState) =&gt; {
  
      if (media) {
        // ... here I extract the values I need and override the initialState where required 
      } else {
        return initialState
      }
    }
  
    const [formState, dispatch] = useReducer(
      MediaFormReducer,
      initialState,
      init
    )
  </code></pre>