Skip to content

Commit 1685609

Browse files
harsh-h-simformdhruv-h-simform
authored andcommitted
fix(UNT-T17140): redial slider render issue
1 parent a2624ab commit 1685609

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/components/RadialSlider/RadialSlider.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Svg, {
55
LinearGradient,
66
Stop,
77
Circle,
8-
Color,
98
NumberProp,
109
} from 'react-native-svg';
1110
import { View, Platform, StyleSheet } from 'react-native';
@@ -48,7 +47,6 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
4847
leftIconStyle,
4948
rightIconStyle,
5049
stroke,
51-
onChange = () => {},
5250
} = props;
5351

5452
const { panResponder, value, setValue, curPoint, currentRadian, prevValue } =
@@ -109,14 +107,12 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
109107

110108
return prevState + step;
111109
});
112-
onChange(value);
113110
} else if (type === 'down' && min < value) {
114111
setValue((prevState: number) => {
115112
prevValue.current = prevState - step;
116113

117114
return prevState - step;
118115
});
119-
onChange(value);
120116
}
121117
};
122118

@@ -147,7 +143,7 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
147143
(
148144
item: {
149145
offset: NumberProp | undefined;
150-
color: Color | undefined;
146+
color: string | undefined;
151147
},
152148
index: React.Key | null | undefined
153149
) => (

src/components/RadialSlider/SpeedoMeter.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Svg, {
44
Defs,
55
LinearGradient,
66
Stop,
7-
Color,
87
NumberProp,
98
Linecap,
109
} from 'react-native-svg';
@@ -96,7 +95,7 @@ const SpeedoMeter = (
9695
(
9796
item: {
9897
offset: NumberProp | undefined;
99-
color: Color | undefined;
98+
color: string | undefined;
10099
},
101100
index: React.Key | null | undefined
102101
) => (

src/components/RadialSlider/hooks/useSilderAnimation.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useState, useRef, useEffect } from 'react';
1+
import { useEffect, useRef, useState } from 'react';
22
import {
3-
PanResponder,
43
GestureResponderEvent,
4+
PanResponder,
55
PanResponderGestureState,
66
} from 'react-native';
77
import {
@@ -51,6 +51,20 @@ const useSilderAnimation = (props: RadialSliderAnimationHookProps) => {
5151
// eslint-disable-next-line react-hooks/exhaustive-deps
5252
}, [max, min]);
5353

54+
useEffect(() => {
55+
if (min <= props?.value && max >= props?.value) {
56+
setValue(props?.value);
57+
prevValue.current = props?.value;
58+
}
59+
// eslint-disable-next-line react-hooks/exhaustive-deps
60+
}, [props?.value]);
61+
62+
useEffect(() => {
63+
onChange(value);
64+
prevValue.current = value;
65+
// eslint-disable-next-line react-hooks/exhaustive-deps
66+
}, [value]);
67+
5468
const handlePanResponderGrant = () => {
5569
moveStartValue = prevValue.current;
5670
moveStartRadian = getRadianByValue(

0 commit comments

Comments
 (0)