From 17ae625d6ee1e2184b52026cf433434441c11fa1 Mon Sep 17 00:00:00 2001 From: Emmet McPoland Date: Tue, 5 Sep 2017 15:30:18 +0100 Subject: [PATCH] Pass the DOM element in onChange Pass the DOM element in onChange. Allows the ability to set data attributes and access them in onChange. Useful for lists. Could pass `this` instead, and/or remove visibilityRect and instead just pass the element, as visibilityRect is easily accessed from the element. --- visibility-sensor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visibility-sensor.js b/visibility-sensor.js index ea26764..d93bbfe 100644 --- a/visibility-sensor.js +++ b/visibility-sensor.js @@ -306,7 +306,7 @@ module.exports = createReactClass({ visibilityRect: visibilityRect }; this.setState(state); - if (this.props.onChange) this.props.onChange(isVisible, visibilityRect); + if (this.props.onChange) this.props.onChange(isVisible, visibilityRect, el); } return state;