Frontend Development 20 min read

React Rendering Performance Optimization: Case Study and Practical Techniques

This article explains common React performance‑optimization methods, walks through a real‑world form‑editor use case, details the profiling, diagnosis, and step‑by‑step improvements—including memoization, callback stabilization, diff filtering, and pure‑function components—that reduced render time from 195 ms to under 10 ms.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
React Rendering Performance Optimization: Case Study and Practical Techniques

Introduction

Performance optimization is a perpetual concern for front‑end developers. As application complexity grows, keeping a smooth user experience becomes increasingly challenging. This article first outlines common React performance‑optimization techniques and then shares a concrete case study of a form‑editor component where we investigated and resolved severe rendering lag.

React Performance Optimization Basics

React already employs many high‑performance strategies: a virtual DOM to minimise direct DOM operations, an efficient diff (reconciliation) algorithm with O(n) complexity, and the Fiber architecture that uses JavaScript Generator functions to enable interruptible rendering and priority‑based scheduling.

What Should We Do?

Building on these foundations, we aim to help React traverse and render faster by keeping the update chain as short as possible. The core goals are:

Control the scope of component re‑renders – only update what truly changed, using React.memo to skip unnecessary work.

Avoid unnecessary prop changes – memoise objects, arrays, and callbacks with useMemo and useCallback , and keep context values stable.

Reduce redundant or meaningless setState calls – batch state updates and avoid storing UI‑only data in React state.

From a Real Business Requirement

The project required a dynamic template field editor: a left‑hand form generated from a JSON‑Schema (using Ant Design Form) and a right‑hand live preview rendered from an HTML‑like template engine. The component needed to support dozens of form fields and hundreds of template placeholders, and it could be instantiated multiple times on a page.

Optimization Results

Optimization Method

Before (ms)

After (ms)

Improvement

Memo to block whole‑form re‑render, useCallback for callbacks

195

88.3

54.71%

Custom lightweight diff to cut unnecessary setState

88.3

25.9

70.6%

useMemo for heavy calculations, extract pure function components, wrap with Memo

25.9

9.5

63.3%

Total

195

9.5

95.14%

Performance Testing

We built an extreme test case with 90 form items (including a table component) and 152 template placeholders. Initial measurements showed a single field focus took 171 ms, value change 195 ms, and blur 140 ms, clearly unacceptable for a 60 Hz UI (target < 16.6 ms per frame).

Investigation Process

Using React DevTools Profiler, we discovered that any change to a form field triggered a full form re‑render. Disabling onFieldsChange reduced the cost to 0.9 ms, indicating the bottleneck lay in the state‑sync and template‑parsing logic rather than Ant Design Form itself.

1. Form Re‑render Issue

We split the Form into a separate memoised component and ensured its props remained stable. This alone cut the render time from 195 ms to 88.3 ms (≈55 % improvement).

2. Unnecessary State Updates

We added a lightweight diff inside onFieldsChange that compares new primitive values with the previous ones; identical updates are ignored, preventing a full state replacement. This reduced the time further to 25.9 ms (≈71 % improvement).

3. Heavy Computation with useMemo

Even after the previous steps, the outer component still spent ~66 ms of the 88 ms on work. We examined two custom hooks:

useFieldList – pre‑processes static form configuration; already memoised and not a hotspot.

useTemplate – parses the template on every form‑value change; this is inherently expensive.

Because the template must update instantly, debouncing was not an option. We therefore focused on reducing the cost of the surrounding component tree.

4. Pure Function Components with Memo

Many small sub‑components (e.g., each placeholder wrapped in a Popover) performed trivial work but added up when thousands existed. By extracting them into pure function components and wrapping with React.memo , we eliminated their redundant renders, bringing the final per‑interaction cost down to 9.5 ms (≈95 % total improvement).

Conclusion

The investigation identified three key optimisation strategies: limit the ripple effect of component re‑renders, keep prop values stable, and avoid frequent, unnecessary setState calls. Applying memoisation, callback stabilisation, lightweight diffs, and pure‑function components reduced the form editor’s render time from 195 ms to under 10 ms, delivering a smooth, lag‑free user experience.

frontendPerformance OptimizationState ManagementReactmemouseCallbackuseMemo
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.