React provides several smaller yet powerful features and utilities that don’t fall under core rendering or hooks — but are essential for building robust, maintainable applications.
In this section, you’ll explore helper tools, debugging utilities, and advanced patterns that boost productivity and code clarity.
classnames, react-error-boundary, etc.The following example combines StrictMode (for highlighting potential issues) and the Profiler (for measuring render performance).
// Import React and Profiler from the core library
import React, { Profiler } from "react";
import MyComponent from "./MyComponent";
function App() {
// Callback function to log performance data
const onRender = (id, phase, actualDuration) => {
console.log(`${id} rendered in ${actualDuration}ms during ${phase}`);
};
return (
// StrictMode highlights potential problems in development
<React.StrictMode>
// Profiler measures the cost of rendering
<Profiler id="MyComponent" onRender={onRender}>
<MyComponent />
</Profiler>
</React.StrictMode>
);
}
export default App;
Why use Portals? Often, parents have CSS like overflow: hidden or z-index stacking contexts that clip child elements. Portals let you logically render a child inside a component, but physically place it at the end of the <body> tag.
This box has overflow: hidden.
If the modal were a normal child, it would be clipped inside this box.
| Utility | Purpose | Key Benefit |
|---|---|---|
StrictMode |
Highlights potential issues during development | Improves code reliability |
Profiler |
Measures render performance and durations | Helps optimize slow components |
Portals |
Render elements outside parent DOM node | Useful for modals, popups, and tooltips |
Refs |
Directly access DOM elements or child instances | Enables advanced control and animations |
| Custom Hooks | Encapsulate logic into reusable functions | Reduces code duplication |
StrictMode only in development — it runs renders twice intentionally to catch bugs.Profiler with React DevTools for deeper insights into component re-renders./hooks folder for reusability.React.StrictMode and observe console warnings.Profiler callbacks in a heavy component.useLocalStorage to persist state data between reloads.ReactDOM.createPortal() that sits outside the main app container.Goal: Gain awareness of React’s essential utilities that enhance performance, maintainability, and developer productivity.