title: how to use data setting in react componentWillMount?
body: <p>I want to get initial Data when component is rendering before.<br>
  So, I try to state update action in componentWillMount.<br>
  Although state change, when I confirm console result at componentDidMount result is blank. </p>
  
  <p>imageUpload.js</p>
  
  <pre><code>export const IMAGE_UPLOAD = 'IMAGE_UPLOAD';
  export function imageUpload(photo) {
    return {
      type: IMAGE_UPLOAD,
      photo
    }
  }
  </code></pre>
  
  <p>Reducers.js</p>
  
  <pre><code>import { IMAGE_UPLOAD } from './actions/imageUpload';
  
  export default function imageUpload(state = {photo: ''}, action) {
    switch(action.type) {
      case IMAGE_UPLOAD:
        return {
          ...state,
          photo: action.photo
        }
      default:
        return state
     }
  }
  </code></pre>
  
  <p>App.js</p>
  
  <pre><code>import photo from './data/photo.json' // photo type: json
  import imageUpload from './actions/imageUpload'
  
  componentWillMount() {
    Storage.prototype.setObject = (key, value) =&gt; {
      this.setItem(key, JSON.stringify(value))
    }
    Storage.prototype.getObject = (key) =&gt; {
      return this.getItem(key) &amp;&amp; JSON.parse(this.getItem(key))
    }
    const photoData = localStorage.getObject('photos');
    if(photoData) // data in localStorage
      imageUpload(photoData) // state setting localStorage data
    else // data not in localStorage
      imageUpload(photo) // state setting photo json data
  }
  
  componentDidMount() {
    console.log(this.props.photo); // result: blank ( I want result: any value)
  }
  
  class App extends React.Component {
    // ...
  }
  
  const mapStateToProps = (state) =&gt; ({
    photo: state.imageUpload.photos
  })
  
  const mapDispatchToProps = (dispatch) =&gt;({
    imageUpload: bindActionCreators(imageUpload, dispatch)
  })
  
  export default connect(mapStateToProps, mapDispatchToProps)(App)
  </code></pre>
  
  <p>What sholud I do?<br>
  Thank you.</p>