scrollmonitor-react icon indicating copy to clipboard operation
scrollmonitor-react copied to clipboard

Feature Request: PureWatch

Open guillaumearm opened this issue 6 years ago • 1 comments

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 ? 🤔

guillaumearm avatar Sep 14 '18 16:09 guillaumearm

I was recently frustrated with this exact problem! It's definitely something I want to do.

stutrek avatar Sep 14 '18 17:09 stutrek