react-dom-utils icon indicating copy to clipboard operation
react-dom-utils copied to clipboard

[RFC] Switch mapPropsOnScroll to withWindowScroll

Open wuct opened this issue 9 years ago • 1 comments

The propMapper of mapPropsOnScroll() currently accept two args

(nextScroll, prevScroll): Object => {}

IMHO prevScroll might be not used in some cases, so we should let consumers to save it by themselves if they need it. It is easily to achieve by using recompose/mapProps or rx-recompose/mapPropsStream and is already implemented in React componentWillReceiveProps().

If mapPropsOnScroll only provides nextScroll, it would be no difference to compose(withWindowScroll, mapProps) where withWindowScroll simply append scroll to props.

In addition, withWindowScroll would be more consistent with other HOCs in react-dom-utils.

@evenchange4 what do you think?

wuct avatar Apr 28 '16 03:04 wuct

Actually, not. I think we should refactor some of withXXXs to mapPropsOnXXXs.

To implement a withXXX, we have to be opinionated on two things:

  1. The name of the prop to append. For examples: windowSize, DOMSize or mousePosition.
  2. The events to listen to. For examples, resize, mousemove or mouseleave.

To implement a mapPropsOnXXX, we can avoid them.

wuct avatar Apr 28 '16 17:04 wuct