react-benchmark icon indicating copy to clipboard operation
react-benchmark copied to clipboard

feat: add onReady feature

Open goooseman opened this issue 2 years ago • 1 comments

Adds a special --onReady flag.

Measure time not until the first render, but until onReady callback is not invoked from the component. Useful when you have something happening inside your component after the initial render. If enabled, a special onReady function is passed to the component as a prop, which can be called after the component has done all the initial tasks, for example:

// Your component

const FooComponent = ({ onReady }) => {
  useEffect(() => {
    doSomeHeavyCalculations().finally(() => onReady())
  }, [])
  return ()
}

goooseman avatar Aug 21 '22 18:08 goooseman

Tests are failing nevertheless they pass locally, will check tomorrow

goooseman avatar Aug 21 '22 19:08 goooseman