I've noticed that React only freezes the props shallowly, and that React.cloneElement only merges in props shallowly. So should we only be passing in props shallowly when we can?
You can definitely pass objects in props, I don't think it is a bad practice at all, although it's a good idea to define PropTypes
on your component so that its users know what to pass in.
I'd also suggest looking into making your model immutable. Immutable objects are always 'frozen', plus they have other benefits, like allowing you to implement shouldComponentUpdate
in a very efficient way, do deep comparison / deep cloning trivially etc. This kind of thing plays really well with react.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With