Advertisements

Loop through components in React

Advertisements

Loop through components in React

render () {
	const comp_render = [];
	for (let dt of this.state.your_data) {
	  comp_render.push(<MyComponent>{dt}</MyComponent>);
	}
	return (
	  <>
	  	{comp_render}
	  </>
	);
}

click for more React codes, read about react doc