That's a good article and I agree with a lot of it. In general, the problem with spreading props is obscurity and messiness. Child components end up accumulating a lot of stuff that is not meant for them and the origin can become obscured.
Even the React docs state...
Spread attributes can be useful but they also make it easy to pass unnecessary props to components that don’t care about them or to pass invalid HTML attributes to the DOM. We recommend using this syntax sparingly.
Agreed. It would be more precise to say passing unnecessary props to a component is a bad practice. Spreading props is merely a technique allowed by JS. This got me thinking, does React warn when a component receives an unexpected prop, and turns out there is a pluggable solution - github.com/airbnb/prop-types-exact
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That's a good article and I agree with a lot of it. In general, the problem with spreading props is obscurity and messiness. Child components end up accumulating a lot of stuff that is not meant for them and the origin can become obscured.
Even the React docs state...
Agreed. It would be more precise to say passing unnecessary props to a component is a bad practice. Spreading props is merely a technique allowed by JS. This got me thinking, does React warn when a component receives an unexpected prop, and turns out there is a pluggable solution - github.com/airbnb/prop-types-exact