title: Passing props to useState React
body: <p>I' am trying to use props coming from redux as a starting point for rendering my state-full component like this:</p>
  
  <pre><code>const MyComp = (props) =&gt; {
  
      const initState = {
          newAttribs: [...props.attribs]
          };
  
      const [state, setState] = useState(initState)
      console.log(state)
  
  };
  
  const mapStateToProps = (fromRedux) =&gt; {...};
  const mapDispatchToProps = (dispatch) =&gt; {...};
  
  export default connect(mapStateToProps, mapDispatchToProps)(React.memo(MyComp));
  </code></pre>
  
  <p>But if I <code>console.log(state)</code> it shows empty array for <code>newAttribs</code> even though in <code>initState newAttribs</code> are there.</p>
  
  <p>Can someone shed some light on how to do this properly?
  Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>I've made an error while posting code snippet, I updated it now.
  <code>const mapStateToProps</code> and <code>const mapDispatchToProps</code> obviously have to be outside of the component scope and they are.</p>