Performance: React ecosystem overview
This affects initial page load speed, bundle size, and runtime rendering performance depending on which React ecosystem tools and libraries are used.
import { useState, useContext, createContext } from 'react'; const MyContext = createContext(); // Use React's built-in hooks and context for local state
import { createStore } from 'redux'; const store = createStore(reducer); // Using Redux everywhere with many connect() wrappers
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy state libraries (Redux everywhere) | High (many connected components) | Multiple reflows per update | High paint cost | [X] Bad |
| React hooks and context for local state | Moderate (scoped updates) | Single reflow per update | Moderate paint cost | [OK] Good |
| Data fetching in many components | Low DOM ops | Blocks rendering until data arrives | Delays paint | [X] Bad |
| Server Components or React Query caching | Low DOM ops | Non-blocking rendering | Fast paint | [OK] Good |
| CSS-in-JS runtime styling | Low DOM ops | Triggers style recalculation on mount | Moderate paint cost | [X] Bad |
| Static CSS modules or Tailwind CSS | Low DOM ops | No runtime style recalculation | Low paint cost | [OK] Good |
useState hook from React?import { useState } from 'react';.import React, { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}import { BrowserRouter, Route } from 'react-router-dom';
function App() {
return (
<BrowserRouter>
<Route path='/home' component={Home} />
</BrowserRouter>
);
}Route uses element prop with JSX, not component.Pass the test and this pattern moves unknown