title: How to cycle through an array of pictures
body: <p>I'm trying to have a Snapchat story-like feature where an array of pictures is displayed for a set period of seconds and than go back to the previous navigation.</p>
  
  <p>Something like the following:</p>
  
  <pre class="lang-js prettyprint-override"><code>if (props.length &gt; 0) {    
      let timeout;
      if (props.length - 1 === index) {
          clearTimeout(timeout)
          navigation.goBack()
      }
  
      if (props[index].image) {
          timeout = setTimeout(() =&gt; {
              setIndex(index + 1)
          }, 3000)
          return &lt;Image source={{ uri: props[index].image }} style={{ flex: 1 }} /&gt;
      }
  }
  </code></pre>
  
  <p>But, this is showing unpredictable results.</p>