title: How can I setState and push object to array?
body: <p>How can I <code>setState</code> and push to an array?
  Currently nothing happens... </p>
  
  <p>This is my code</p>
  
  <p>State</p>
  
  <pre><code>const [imageData, setImageData] = useState([]);
  </code></pre>
  
  <p>crop image</p>
  
  <pre><code>const choosePicture = () =&gt; {
      ImagePicker.openPicker({
          width: 300,
          height: 400,
          cropping: true,
      })
          .then(image =&gt; {
              onSelectedImage(image);
          })
          .catch(error =&gt; {
              console.log(error);
          });
  };
  </code></pre>
  
  <p>setState</p>
  
  <pre><code>const onSelectedImage = image =&gt; {
      let newDataImg = imageData;
  
      let item = {
          id: Date.now(),
          url: image.path,
      };
  
      newDataImg.push(item);
      setImageData(newDataImg);
  };
  console.log(imageData);
  </code></pre>
  
  <p>And Flatlist</p>
  
  <pre><code>&lt;FlatList
      data={imageData}
      renderItem={itemData =&gt; (
          &lt;View&gt;
              &lt;Image
                  source={{uri: itemData.item.url}}
                  style={{width: 200, height: 200}}
              /&gt;
          &lt;/View&gt;
      )}
      keyExtractor={item =&gt; item.id.toString()}
  /&gt;
  </code></pre>