Generators are special type of functions in java script that can pause and resume state which would be helpful in asynchronous coding
import React, { Component } from 'react'; class Projects extends Component { render() { //Return has to be in one element one Div"use strict"; /*generator function declaration .It yields a generator To be a generator it should be iterable */ function* neverEnding(){ let index =0; while (true) { //returning a generator yield index++; } } //intantiate the generator let gen =neverEnding(); console.log(gen.next); return ( <div className="Projects"> My Projects {this.props.test} </div> ); } } export default Projects;
No comments:
Post a Comment