Skip to content

Commit 5d5a8df

Browse files
committed
fix: remove refs from the progress bars
1 parent 4fb9a21 commit 5d5a8df

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

package/src/components/ProgressControl/ProgressControl.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useMemo, useRef, useState } from 'react';
1+
import React, { useMemo, useState } from 'react';
22
import { StyleSheet, View } from 'react-native';
33
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
44
import Animated, {
@@ -77,7 +77,6 @@ export const ProgressControl = (props: ProgressControlProps) => {
7777
const { filledColor: filledColorFromProp, onEndDrag, onStartDrag, progress, testID } = props;
7878

7979
const state = useSharedValue(progress);
80-
const isSliding = useRef(false);
8180
const {
8281
theme: {
8382
colors: { grey_dark },
@@ -88,19 +87,16 @@ export const ProgressControl = (props: ProgressControlProps) => {
8887
useAnimatedReaction(
8988
() => progress,
9089
(newProgress) => {
91-
if (!isSliding.current) {
92-
state.value = newProgress;
93-
}
90+
state.value = newProgress;
9491
},
95-
[progress, isSliding],
92+
[progress],
9693
);
9794

9895
const pan = useMemo(
9996
() =>
10097
Gesture.Pan()
10198
.maxPointers(1)
10299
.onStart(() => {
103-
isSliding.current = true;
104100
if (onStartDrag) {
105101
runOnJS(onStartDrag)(state.value);
106102
}
@@ -110,7 +106,6 @@ export const ProgressControl = (props: ProgressControlProps) => {
110106
state.value = newProgress;
111107
})
112108
.onEnd(() => {
113-
isSliding.current = false;
114109
if (onEndDrag) {
115110
runOnJS(onEndDrag)(state.value);
116111
}

package/src/components/ProgressControl/WaveProgressBar.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useMemo, useRef, useState } from 'react';
1+
import React, { useCallback, useMemo, useState } from 'react';
22
import { Platform, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
33
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
44
import Animated, {
@@ -89,7 +89,6 @@ export const WaveProgressBar = React.memo(
8989
const eachWaveformWidth = WAVEFORM_WIDTH * 2;
9090
const fullWidth = (amplitudesCount - 1) * eachWaveformWidth;
9191
const state = useSharedValue(progress);
92-
const isSliding = useRef(false);
9392
const [currentWaveformProgress, setCurrentWaveformProgress] = useState<number>(0);
9493

9594
const waveFormNumberFromProgress = useCallback(
@@ -106,9 +105,7 @@ export const WaveProgressBar = React.memo(
106105
useAnimatedReaction(
107106
() => progress,
108107
(newProgress) => {
109-
if (!isSliding.current) {
110-
state.value = newProgress;
111-
}
108+
state.value = newProgress;
112109
waveFormNumberFromProgress(newProgress);
113110
},
114111
[progress],
@@ -125,7 +122,6 @@ export const WaveProgressBar = React.memo(
125122
.enabled(showProgressDrag)
126123
.maxPointers(1)
127124
.onStart(() => {
128-
isSliding.current = true;
129125
if (onStartDrag) {
130126
runOnJS(onStartDrag)(state.value);
131127
}
@@ -136,7 +132,6 @@ export const WaveProgressBar = React.memo(
136132
waveFormNumberFromProgress(newProgress);
137133
})
138134
.onEnd(() => {
139-
isSliding.current = false;
140135
if (onEndDrag) {
141136
runOnJS(onEndDrag)(state.value);
142137
}

0 commit comments

Comments
 (0)