Spreading Props on DOM elements
Last updated
Was this helpful?
Last updated
Was this helpful?
When you spread the props, you run into the risk of adding unknown HTML attributes, which is a bad practice.
This will try to add the unknown HTML attribute flag
to the DOM element.
By creating props specifically for DOM attribute, we can safely spread.
Or alternatively we can use prop destructuring with ...rest
:
Notes
In scenarios where you use a , when an update happens it re-renders the component even if domProps
did not change. This is because PureComponent only the objects.