Guest User

Untitled

a guest
Dec 17th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import React, { Component } from 'react'
  2.  
  3. let start = 0
  4. let stop = 0
  5.  
  6. class App extends Component {
  7. constructor(props) {
  8. super(props)
  9. this.state = {
  10. listLength: 20000
  11. }
  12. this.rerenderList = this.rerenderList.bind(this)
  13. }
  14.  
  15. componentDidUpdate() {
  16. stop = performance.now()
  17. console.log('rerender', stop - start)
  18. }
  19.  
  20. rerenderList() {
  21. this.setState({
  22. listLength: 20000
  23. })
  24. start = performance.now()
  25. }
  26.  
  27. render() {
  28. const LIST_LENGTH = this.state.listLength
  29. return (
  30. <div>
  31. <button onClick={this.rerenderList}>Rerender</button>
  32. <ul>
  33. {
  34. Array.apply(null, Array(LIST_LENGTH)).map(function (x, i) {
  35. return (<li key={i}>{Math.random()}</li>)
  36. })
  37. }
  38. </ul>
  39. </div>
  40. )
  41. }
  42. }
  43.  
  44. export default App
Add Comment
Please, Sign In to add comment