My app has a user control panel and when the page is loaded it fetch data from the server using Redux.
In construction the component create an initial state like:
const { profile } = this.props;
this.state = {
  prop1: profile.prop1 || '',
  prop2: profile.prop2 || '',
  nested: {
    nestedProp1: profile.nested.nestedProp1 || '',
  }
  ...etc...
}
On componentWillMount I have this:
componentWillMount() {
  const { user, getProfile } = this.props;
  if (user.profile_id) {
    getProfile(user.profile_id);
  }
}
What I don't understand are 2 things:
- Is the approach correct? I'm using state to handle form inputs.
- How can I update the state when fetched? There are plenty of properties in this profile object and I was wondering to update all the states in a very simple way, and not one by one...
 
     
    