From 6ca5853341022cfc85e0e114ad893582f29dfb97 Mon Sep 17 00:00:00 2001 From: Nick Dancer Date: Thu, 17 Nov 2022 12:15:53 +1000 Subject: [PATCH] refactor: avoid manipulating state directly --- src/components/ReactSlider/ReactSlider.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ReactSlider/ReactSlider.jsx b/src/components/ReactSlider/ReactSlider.jsx index 6a8fdda..7f548a6 100644 --- a/src/components/ReactSlider/ReactSlider.jsx +++ b/src/components/ReactSlider/ReactSlider.jsx @@ -836,7 +836,10 @@ class ReactSlider extends React.Component { } move(newValue) { - const { index, value } = this.state; + // Clone this.state.value since we'll modify it temporarily + // eslint-disable-next-line zillow/react/no-access-state-in-setstate + const value = this.state.value.slice(); + const { index } = this.state; const { length } = value; // Short circuit if the value is not changing