From 2ca1629af2b2157c8fb487156c2a94de403b604b Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Sat, 31 Oct 2020 12:48:51 +0100 Subject: [PATCH] fix(usePolling): Do not modify original intervals array when checking sorting --- CHANGELOG.md | 3 +++ src/usePolling.js | 2 +- test/hocs.spec.js | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c703c8..bdcdaf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - chore(deps): Update dependencies +### Fixed +- fix(usePolling): Do not modify original intervals array when check sorting + ## [1.2.0] - 2020-06-21 ### Added diff --git a/src/usePolling.js b/src/usePolling.js index 1f96084..f44527c 100644 --- a/src/usePolling.js +++ b/src/usePolling.js @@ -25,7 +25,7 @@ class PollingHandler { } _checkInterval() { - const sortedIntervals = this._intervalTimes.sort((a, b) => a - b); + const sortedIntervals = [...this._intervalTimes].sort((a, b) => a - b); if (sortedIntervals[0] !== this._currentIntervalTime) { this._clearInterval(); this._currentIntervalTime = sortedIntervals[0]; diff --git a/test/hocs.spec.js b/test/hocs.spec.js index 51a927c..ab0aba0 100644 --- a/test/hocs.spec.js +++ b/test/hocs.spec.js @@ -62,7 +62,7 @@ describe("HOCs", () => { }); it("should wrap displayName of the component using name property if component has not displayName", async () => { - const BooksComponent = ({ data }) => { + BooksComponent = ({ data }) => { return ; }; BooksComponent.displayName = null;