Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Warning: React does not recognize a prop on a DOM element

ErrorWarning: React does not recognize the `isActive` prop on a DOM element.

Short answer

React shows this warning when a prop reaches a real HTML element that does not understand it. The usual cause is spreading all props onto a div or button, including ones meant for your own component. Pull those props out before spreading the rest, use data-* for custom data, and name components in PascalCase.

  • Applies to React 19, Next.js 15
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    The warning names the prop. Search your code for where that prop is passed down, and check whether a {...props} spread sits between it and a DOM tag.

    grep -rn "{\.\.\.props}\|{\.\.\.rest}" src/
  2. 2Match what you see, then jump to its fix

    1. 1The named prop is one your own component uses, such as layout or isActiveProps are spread onto a DOM element along with parent-only propsFix
    2. 2The prop is something you invented on a plain tag, for example <div layout="horizontal">A non-standard attribute is used to store custom dataFix
    3. 3The warning appears on a tag you thought was your own component, such as <myButton>A component name starts with a lowercase letterFix

What does the error look like?

  • Warning: React does not recognize the `isActive` prop on a DOM element.
  • Warning: Unknown event handler property
  • Warning: Received `true` for a non-boolean attribute

Cause 1 of 3

Props are spread onto a DOM element along with parent-only props

1Check

Find the component whose JSX has {...props} on a div, button or similar. Any prop the parent set, but the element does not know, is forwarded.

grep -n "<div {...props}\|<button {...props}" -r src/

2Fix

Destructure the props your component uses and spread only the remainder onto the element.

function MyDiv(props) {
  const { layout, ...rest } = props;
  const style = layout === 'horizontal' ? getHorizontalStyle() : getVerticalStyle();
  return <div {...rest} style={style} />;
}

3Verify

Reload the page and confirm the warning is gone from the console.

npm run dev

Confirmed by react.dev

Did this fix it?

Cause 2 of 3

A non-standard attribute is used to store custom data

1Check

Search the markup for attributes that are not standard HTML or React DOM props.

grep -rn "<div [a-z]*=" src/ | head

2Fix

Use a data-* attribute for custom data. React documents that custom attribute names must be lowercase and must not start with on.

// before
<div layout="horizontal" />
// after
<div data-layout="horizontal" />

3Verify

Reload and check that the warning no longer lists the attribute.

npm run dev

Confirmed by react.dev

Did this fix it?

Cause 3 of 3

A component name starts with a lowercase letter

1Check

JSX treats lowercase tag names as DOM tags, so the props of <myButton /> are checked against HTML.

grep -rn "<[a-z][A-Za-z]*[A-Z]" src/ --include=*.jsx --include=*.tsx

2Fix

Rename the component and every use of it in PascalCase.

// wrong: rendered as a DOM tag
<myButton />
// right
<MyButton />

3Verify

The warning is gone and the component renders its own markup.

npm run dev

Confirmed by react.dev

Did this fix it?

How do I stop it coming back?

  • Never spread props onto a DOM element without first removing the props your own component consumes.
  • Use camelCase DOM names (className, htmlFor, tabIndex) and lowercase names for custom attributes.
  • Keep custom data in data-* attributes, or in props and state.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

next/link throws React.Children.only on its children

Error: React.Children.only expected to receive a single React element child.

React.Children.only accepts exactly one React element and throws for anything else, including an array with one item.

3 causes, each with a fix

Web apps

Hydration failed after adding next-themes dark mode

Console reports a server and client mismatch on the html element

next-themes changes the html element and knows the theme only in the browser, so server HTML and client HTML differ.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.