Skip to content
>_VibeUnstuck

React does not recognize the prop on a DOM element

Last verified:

The fix

React does not recognize the prop on a DOM element. A custom prop was spread onto a DOM node. Destructure it off before the spread. Do not lowercase it unless you meant it as an attribute.

  1. 1

    Read the prop name in the warning

    That identifier is the one to remove from the DOM node. Search the component that renders the tag, not the whole design system, for a spread that still contains it.

  2. 2

    Destructure custom props before you spread the rest

    Pull isActive and any other custom field out of the props, then spread what remains onto the DOM node. Use the custom field in the component. Do not pass it through.

    function Button({
      isActive,
      ...rest
    }: {
      isActive?: boolean;
    } & React.ButtonHTMLAttributes<HTMLButtonElement>) {
      return (
        <button
          type="button"
          data-active={isActive ? "" : undefined}
          {...rest}
        />
      );
    }
  3. 3

    Keep asChild and refs on the wrapper

    If the warning names asChild, that prop was spread onto the DOM node. The wrapper should read it and not forward it. A ref warning is a different sentence. Do not add asChild to a native <button> to silence this one.

  4. 4

    Lowercase only an attribute you want in the HTML

    React's hint applies when the attribute is intentional. Prefer data-active over a lowercased camelCase name. Do not rename a callback or a boolean to lowercase and keep spreading it. The warning would stop and the DOM would gain a useless attribute.

Why it happens

React warns that it does not recognize the isActive prop on a DOM element. The name in the warning is whatever you passed. The rest of the sentence says to spell it as lowercase isactive if you intentionally want it in the DOM as a custom attribute, or to remove it from the DOM element if a parent passed it by accident. DOM nodes only accept attributes React knows, plus data-* and aria-*.

Generated components and shadcn-style wrappers do {...props} on a <button> or <div> after a parent passed isActive, asChild, or another custom field. React forwards that field to the DOM and warns. The lowercase hint is for an attribute you actually want in the HTML. A boolean prop lowercased to isactive still shows up as an attribute and does not fix the component API. asChild belongs to the wrapper, not to the DOM node. A hydration mismatch is a different warning. An unknown prop on your own function component is not this warning, because that component can accept it.

The next error you'll probably hit

Once this is fixed, the usual follow-up is Each child in a list should have a unique "key" prop. Each child in a list should have a unique "key" prop. Put a stable id on the element returned from map. Do not use Math.random(), and do not use the array index when the list can reorder.

Prompt to paste back into your AI tool

Paste this above the error.

React warns: React does not recognize the `<prop>` prop on a DOM element. The component is:
<paste the component that renders the DOM node>

Do not lowercase the prop to hide the warning unless we intend an HTML attribute. Do not delete the prop from the parent if the component still needs it. Do not spread {...props} onto the DOM node while custom fields are still in props.

1. Destructure the named prop, and any other custom fields, out of the props before the spread.
2. Use it in the component, or as a data-* attribute if it has to be in the DOM.
3. Do not forward asChild to a DOM node.
4. Change only this component.

Common questions

+The warning says to spell the prop in lowercase. Should I?

Only if you want that string as an HTML attribute. For a component flag such as isActive, destructure it and do not pass it to the DOM node. data-active is the attribute form.

+It only happens after I spread props onto a button. Is the parent wrong?

The parent may pass isActive on purpose. The button element cannot accept it. Take it out of the object you spread. Removing it from the parent drops the behavior the wrapper was supposed to use.

Related errors