DEV Community

Discussion on: A Simple(ish) Application of Javascript Generators in React w/ Redux

Collapse
 
tonixtuft profile image
Anton Bagdatyev (Tonix-Tuft) • Edited

You are yielding null initially on the very first iteration. Therefore I guess this code won't work because of this test:

  useGenerator = () => {
    this.setState({ generatedObj: this.createVideoGenerator().next() }, () => {
      if(!this.state.generatedObj.value){ // <--- this.state.generatedObj.value will be null instead of the first yielded video React element
        this.props.handleChange("ENDED")
      }
    })
  }