scrollmonitor-react
scrollmonitor-react copied to clipboard
Feature Request: PureWatch
Hi 🙂
Let's say I have a class component decorated by the Watch
HOC and I only want to use enterViewport
and leaveViewport
props from outside this component.
My component re-render each-time one of this props change when I don't even use them :
"isBelowViewport"
"isInViewport"
"isAboveViewport"
"isFullyInViewport"
"lockWatcher"
"unlockWatcher"
"startWatcher"
"stopWatcher"
"enterViewport"
"exitViewport"
"onApplicationAdded"
The main idea is to have a way to replace this : https://github.com/stutrek/scrollmonitor-react/blob/master/index.js#L159 by something like :
const omitInternalProps = obj => require('lodash.omit')(obj, [
'autoStart',
'innerRef',
'stateChange',
'visibilityChange',
'enterViewport',
'fullyEnterViewport',
'exitViewport',
'partiallyExitViewport',
]);
return (
<Component {...omitInternalProps(this.props))}>
{this.props.children}
</Component>
);
@stutrek what do you think ? Did I miss something ? 🤔
I was recently frustrated with this exact problem! It's definitely something I want to do.