frontend-challenges icon indicating copy to clipboard operation
frontend-challenges copied to clipboard

16 - re-render

Open marks0351 opened this issue 1 year ago • 0 comments

components/very-slow-component.jsx

import React from "react";

const wait = (ms) => {
  const start = Date.now();
  let now = start;

  while (now - start < ms) now = Date.now();
};

export const VerySlowComponent = React.memo(() => {
  wait(500);
  return null;
});

export const AnotherVerySlowComponent = React.memo(() => {
  wait(500);
  return null;
});

marks0351 avatar Feb 29 '24 12:02 marks0351