только тут надо следить и за update'ом...
import React from 'react'
export default class App extends React.Component {
state = {
items: [
{ id: 1 },
{ id: 2 },
{ id: 3 },
],
show: 1
}
componentDidMount() {
const interval = setInterval(() => {
this.state.show === this.state.items.length
?
clearInterval(interval)
:
this.setState({ show: this.state.show + 1 })
}, 1000)
}
render() {
return this.state.items.slice(0, this.state.show).map(item => <div key={item.id}>{item.id}</div>)
}
}