tezvyn:

Measure Component Render Costs with <Profiler>

Source: react.devadvanced

React's `<Profiler>` is a stopwatch for your components, measuring render times programmatically. Wrap any UI tree to log detailed performance metrics on every update, helping you pinpoint slow renders. The footgun: It's disabled in production by default.

React's `<Profiler>` is a built-in stopwatch that programmatically measures the render cost of a component tree. By wrapping a UI section, its `onRender` callback fires on every update, providing timings like `actualDuration` and `baseDuration`. This is ideal for logging performance metrics to an analytics service to track trends. The footgun: Profiling adds overhead and is disabled in production by default; you must use a special build to enable it, otherwise your callback won't fire.

Read the original → react.dev

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Measure Component Render Costs with <Profiler> · Tezvyn