This standard ensures your React components render correctly and efficiently, preventing common pitfalls that cause errors or performance issues.
Always use stable, unique identifiers as keys when rendering lists:
// โ Avoid using array index as key when items can reorder
{payload.map((item, index) => (
<div key={index}>...</div>
))}
// โ
Use a unique, stable identifier when available
{payload.map((item) => (
<div key={item.value || `${item.dataKey}-${item.name}`}>...</div>
))}
When dealing with components that might render differently on server vs. client, implement hydration safety checks:
const [isMounted, setMounted] = React.useState(false);
React.useEffect(() => {
setMounted(true);
// Additional initialization if needed
}, []);
// Avoid hydration mismatch by not rendering on server
if (!isMounted) {
return null;
}
return <Component {...props} />;
When conditionally showing UI elements or handling state that depends on browser APIs:
This prevents hydration errors, improves SSR compatibility, and ensures consistent rendering across environments.
Enter the URL of a public GitHub repository