Description
No ostensible bug report or feature request, just genuine interest in the internal dialogue of those who design React.
What motivated the decision to introduce the new .memo
feature as a separate, opt-in higher order component rather than just not rendering when a function's props haven't changed?
If I understand correctly, a functional component should, by design, have no side-effects; so it shouldn't matter if it won't re-render when none of the inputs have changed. This alternative approach would enforce this behaviour.
Perhaps it was to maintain backward-compatibility in a point release? Or perhaps it was because functional components don't have any state (and therefore can't by default store any prevProps
objects; but surely React pulls the props from the tree mid-updating [see, for instance, here].)
Any light you can shed on this design decision – and anything else that might seem relevant – would be of great interest to me, and would help me on my way to understanding and appreciating this beautiful framework, and language. Thanks!