This error appears when a React component prop ends up being added as an attribute on a DOM element.
Typically this error will appear when passing props to a component that then uses the spread operator to pass them into another component. Consider a contrived example like this:
const ParentComponent = () => {
return (<ChildComponent showLabel={true} />);
}
const ChildComponent = (props) => {
return (
<div {...props}>blah blah blah</div>
)
}
In this case the showLabel
prop that you passed to ChildComponent
ends up being rendered as an attribute on a div
tag, which isn't allowed as indicated by the error message you're seeing.
Make sure any props that you're passing into a component are accounted for, and if necessary remove them or destructure and only pass the necessary props to the next component:
const ChildComponent = (props) => {
const { someLabel, ...rest } = props;
return (
<div {...rest}>blah blah blah</div>
)
}