I have found Gaurav Singhal sharing great example in terms of how to use React.createElement
:
let WelcomeText = React.createElement(
"h1",
{ style: { color: "blue" } },
"This is a welcome text"
);
This will lead you to have
<h1 style="color:blue">
This is a welcome text
</h1>
but if you are just beginner or slow learner like me, and somehow you just need more reference to know whether there is alternative way, I have found Corentin de Boisset and array.map() both introducing how to use array.map()
in JSX, I myself also use array.map() to play video in JSX and it works:
constructor (props) {
super (props);
this.state = {playList = []}
}
render() {
let dynamicPlayer = this.state.playList.map((items) => {
return (
<ReactPlayer
url= {items.source}//'storage/star_war.mp4'
className='react-player'
width='100%'
height='100%'
volume={items.volume}
controls = {true}
/>)
})
return (
<Container>
<div>{dynamicPlayer}</div>
</Container>
);
}
Though I would recommend React.createElement
as well.