-
-
Save just-boris/ee32cf44191d7298228e4241d4f46d09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
const getItems = prefix => | |
Array.from({ length: 5000 }, (_, index) => ({ | |
id: index, | |
name: `${prefix} ${index}` | |
})); | |
export default class TableNoSetState extends React.Component { | |
state = { | |
items: getItems('before mount') | |
}; | |
componentDidMount() { | |
this.setState({ items: getItems('after mount') }); | |
} | |
render() { | |
return ( | |
<table> | |
<tbody> | |
{this.state.items.map(item => ( | |
<tr key={item.id}> | |
<td>#{item.id}</td> | |
<td>{item.name}</td> | |
</tr> | |
))} | |
</tbody> | |
</table> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment