In my user interface, I am attempting to display each box with a 1-second delay (Box1 after 1 second, Box2 after another 1 second, and so on).
https://i.sstatic.net/FdTkY.png
However, instead of the desired result, I am seeing something different:
https://i.sstatic.net/9zpE2.png
Please review my React code below and help me identify where I may have gone wrong, resulting in the unexpected output showing numbers alongside the boxes:
const CreateBox = (props) => {
return (
<>
{/*<div className="box">{props.num}</div>*/}
<div className="box"></div>
</>
)
}
const App = () => {
return (
<div className="app">
<h3>App</h3>
{
[1,2,3,4,5,6,7,8,9,10].map((item) => {
return setTimeout(() => {
// return (<CreateBox num={item} />)
return (<CreateBox />)
}, 1000)
})
}
</div>
)
}
const root = document.querySelector('#root')
ReactDOM.render(<App />, root)
View on Codepen - https://codepen.io/anon/pen/pBLPMY