title: How to refresh React Flatlist after posting new Item to my Database?
body: <p>I am trying to build a react-native application which is using aws api gateway/lambda and dynamodb as a backend. I have a flatlist which I am populating by making a call to retrieve all items from a database. I have an effect hook which I am using to fetch the data when the component mounts. How do I make the same effect run when/if my post request is successful ?</p>
  <p>This is my effect hook which I am running only once like component did mount.</p>
  <pre><code>useEffect(() =&gt; {
      const fetchData = async () =&gt; {
        const resp = await fetch('MY_AWS_URL')
        const data = await resp.json()
        const exp = data.Items 
        setExp(exp);   //SET THE STATE VARIABLE WITH THE DATA
        setLoading(false); //STOP DISPLAYING DEFAULT SPINNER AND SHOW DATA
      }
      fetchData();
  
    }, []);   
  
  </code></pre>
  <p>I Have a form which will allow me to post new data to the database. How do I automatically refresh my component to display the latest data if my POST request is successful ?</p>