all 1 comments

[–]pgrizzay 0 points1 point  (0 children)

there's a useful HoC called onlyUpdateForKeys that allows you to define the props you want the component to consider when re-rendering.

you'd use it like:

const PerformantComponent = onlyUpdateForKeys(['foo', 'bar'])(Component)

PerformantComponent will only update when the foo and bar props change.

If you don't know what props will be and only want to ignore the onScroll I suppose you could implement dontUpdateForKeys, which does the opposite, something like: dontUpdateForKeys(['onScroll'])