Warning: React does not recognize the `X` prop on a DOM element. (JavaScript) — how to fix
Warning: React does not recognize the `isActive` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `isactive` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
Quick fix: Pull the custom prop out before spreading: const { isActive, ...rest } = props; return <div {...rest} />. With styled-components, use a transient prop ($isActive) or shouldForwardProp. If you really want an attribute in the DOM, use data-active.
What it means
React passes props on host elements (<div>, <button>, <a>) straight to the DOM as attributes. It knows the valid HTML/SVG attribute names. When it sees an unknown camelCase name such as isActive, variant on a <div>, or fullWidth, it warns instead of writing a nonsense attribute. The page still works; the warning tells you a prop leaked to the wrong place.
The component named in the stack below the warning is the one rendering the DOM element.
Cause 1: spreading all props onto a DOM element
function Tab(props) {
return <button {...props} />; // isActive reaches <button>
}
<Tab isActive onClick={select}>Home</Tab>
Destructure your own props out, and spread only the rest:
function Tab({ isActive, ...rest }) {
return (
<button
{...rest}
className={isActive ? "tab active" : "tab"}
aria-selected={isActive}
/>
);
}
Cause 2: styled-components passing style props through
styled-components forwards props to the underlying HTML element:
const Box = styled.div`
color: ${(p) => (p.isActive ? "red" : "black")};
`;
<Box isActive /> // warning
Use a transient prop (prefixed with $), which styled-components does not pass to the DOM (v5.1+):
const Box = styled.div`
color: ${(p) => (p.$isActive ? "red" : "black")};
`;
<Box $isActive />
Or filter props explicitly:
const Box = styled.div.withConfig({
shouldForwardProp: (prop) => prop !== "isActive",
})`...`;
In styled-components v6, unknown props are forwarded by default; the v6 migration guide recommends transient props or a StyleSheetManager with shouldForwardProp (for example using @emotion/is-prop-valid).
Cause 3: Emotion / MUI styled()
Emotion and MUI's styled() accept the same kind of option:
const Root = styled("div", {
shouldForwardProp: (prop) => prop !== "isActive",
})(({ isActive }) => ({
opacity: isActive ? 1 : 0.5,
}));
Cause 4: a library prop on the wrong element
Router and UI-library props such as activeClassName, exact, fullWidth or variant only mean something to their own component. If you put them on a plain <a> or <div>, or wrap a library component in your own component that spreads to a DOM node, the prop leaks. Check you're rendering the library's component (<NavLink>, <Button>), not a raw element.
Cause 5: you actually want a custom attribute
For data you want readable from CSS or element.dataset, use a data- attribute:
<div data-active={isActive ? "true" : "false"} />
[data-active="true"] { font-weight: bold; }
Related warning: non-boolean attribute
If the prop is a lowercase name like active that you passed as true, React instead warns "Received true for a non-boolean attribute active". The fixes are the same: strip it before spreading, or use data-active.
Last updated 2026-12-03.