From 406da7b6fa6cb756f45274e73bd816ef7107b291 Mon Sep 17 00:00:00 2001 From: Gabriel Kalani Date: Tue, 12 Feb 2019 23:41:43 -0200 Subject: [PATCH] Refactor `Destructuring Binding` --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index d5dea7d..55345d6 100644 --- a/src/index.js +++ b/src/index.js @@ -33,8 +33,8 @@ class ScrollTrigger extends Component { } } - componentDidUpdate(prevProps, prevState) { - if (prevProps.throttleScroll !== this.props.throttleScroll) { + componentDidUpdate({throttleScroll, throttleResize}, prevState) { + if (throttleScroll !== this.props.throttleScroll) { removeEventListener('scroll', this.onScrollThrottled); this.onScrollThrottled = throttle(this.onScroll.bind(this), this.props.throttleScroll, { trailing: false, @@ -42,7 +42,7 @@ class ScrollTrigger extends Component { addEventListener('scroll', this.onScrollThrottled); } - if (prevProps.throttleResize !== this.props.throttleResize) { + if (throttleResize !== this.props.throttleResize) { removeEventListener('resize', this.onResizeThrottled); this.onResizeThrottled = throttle(this.onResize.bind(this), this.props.throttleResize, { trailing: false,