title: How to make react input show state value?
body: <p>I have <code>title</code> and <code>message</code> variables as the local state in my React component. The idea is that when the component mounts, these two variables get initialised either with the respective values coming from <code>currentPost</code> object which is coming from Redux, or otherwise with an empty string.</p>
  <pre><code>const MyComponent = ({ currentPost }) =&gt; {
      const [title, setTitle] = React.useState(currentPost.title ? currentPost.title : '');
      const [message, setMessage] = React.useState(currentPost.message ? currentPost.message : '');
  
      &lt;form&gt;
      &lt;div className=&quot;form-group&quot;&gt;
           &lt;input
               value={title}
               onChange={evt =&gt; setTitle(evt.target.value)}
           /&gt;                   
      &lt;/div&gt;
  
      &lt;div className=&quot;form-group&quot;&gt;
           &lt;input
               value={title}
               onChange={evt =&gt; setTitle(evt.target.value)}
           /&gt;                   
      &lt;/div&gt;
      &lt;/form&gt;
  
  
      const mapStateToProps = state =&gt; ({ currentPost: state.posts.currentPost });
  };
  </code></pre>
  <p>The code above is actually a modal that opens whenever I click on the edit icon of a given post. In the same time, the <code>currentPost</code> object on Redux state, which is empty, gets populated with the selected post. Then in the above modal component, I get currentPost from Redux state.</p>
  <p>The problem is that the two variables always get an empty string, even when <code>currentPost</code> is populated with all the data I need. How can I make the input fields show the right data depending on the currentPost state?</p>