Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. class Node extends Component {
  2. componentDidMount() {
  3. this.queueUpdate()
  4. }
  5.  
  6. componentDidUpdate() {
  7. this.queueUpdate()
  8. }
  9.  
  10. queueUpdate = () => {
  11. const {
  12. dispatch,
  13. id,
  14. } = this.props
  15.  
  16. this
  17. .timeoutId = (
  18. setTimeout(
  19. () => {
  20. dispatch(
  21. queueAction(
  22. updateNode(id)
  23. )
  24. )
  25. },
  26. getRandomTimeout(),
  27. )
  28. )
  29. }
  30.  
  31. render() {
  32. const {
  33. color,
  34. value,
  35. x,
  36. y,
  37. } = this.props
  38.  
  39. return (
  40. <div
  41. style={{
  42. color,
  43. left: `${x}ch`,
  44. position: 'absolute',
  45. top: `${y}em`,
  46. }}
  47. >
  48. {value}
  49. </div>
  50. )
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement