re: A Simple(ish) Application of Javascript Generators in React w/ Redux VIEW POST

FULL DISCUSSION
 

for the issue with state being Async, you can also use a callback function to ensure you are setting it to the correct value.

    function* nextVideo(array){
      let nextVideo = null
      while(this.state.counter < array.length) {
        this.setState((prevState) => {
            nextVideo = array[prevState.counter + 1]
            return { counter: prevState.counter + 1 }
        })
        yield nextVideo
      }
    }
code of conduct - report abuse