From 8728a641376b5f5423b1f86aeac375f0d72d4b56 Mon Sep 17 00:00:00 2001 From: mcsf Date: Fri, 9 Feb 2018 11:53:49 +0000 Subject: [PATCH] Address feedback --- components/higher-order/with-safe-timeout/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/higher-order/with-safe-timeout/index.js b/components/higher-order/with-safe-timeout/index.js index a89dc5adce0910..de5fe4b27cdf2c 100644 --- a/components/higher-order/with-safe-timeout/index.js +++ b/components/higher-order/with-safe-timeout/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import { without } from 'lodash'; + /** * WordPress dependencies */ @@ -23,7 +28,6 @@ function withSafeTimeout( OriginalComponent ) { this.timeouts = []; this.setTimeout = this.setTimeout.bind( this ); this.clearTimeout = this.clearTimeout.bind( this ); - this.clear = this.clear.bind( this ); } componentWillUnmount() { @@ -33,7 +37,7 @@ function withSafeTimeout( OriginalComponent ) { setTimeout( fn, delay ) { const id = setTimeout( () => { fn(); - this.clear( id ); + this.clearTimeout( id ); }, delay ); this.timeouts.push( id ); return id; @@ -41,11 +45,7 @@ function withSafeTimeout( OriginalComponent ) { clearTimeout( id ) { clearTimeout( id ); - this.clear( id ); - } - - clear( id ) { - this.timeouts = this.timeouts.filter( t => t !== id ); + this.timeouts = without( this.timeouts, id ); } render() {