@@ -212,24 +212,39 @@ export class Slider extends PureComponent<SliderProps, SliderState> {
212
212
}
213
213
}
214
214
215
- componentDidUpdate ( ) {
216
- const newValues = normalizeValue (
217
- this . props ,
218
- this . props . value instanceof Animated . Value
219
- ? this . props . value . __getValue ( )
220
- : this . props . value ,
221
- ) ;
222
- newValues . forEach ( ( value , i ) => {
223
- if ( ! this . state . values [ i ] ) {
224
- this . _setCurrentValue ( value , i ) ;
225
- } else if ( value !== this . state . values [ i ] . __getValue ( ) ) {
226
- if ( this . props . animateTransitions ) {
227
- this . _setCurrentValueAnimated ( value , i ) ;
228
- } else {
229
- this . _setCurrentValue ( value , i ) ;
230
- }
231
- }
232
- } ) ;
215
+ componentDidUpdate ( prevProps ) {
216
+ // Check if the value prop has changed
217
+ if ( this . props . value !== prevProps . value ) {
218
+ const newValues = normalizeValue ( this . props , this . props . value ) ;
219
+
220
+ this . setState ( {
221
+ values : updateValues ( {
222
+ values : this . state . values ,
223
+ newValues : newValues ,
224
+ } ) ,
225
+ } , ( ) => {
226
+ newValues . forEach ( ( value , i ) => {
227
+ const currentValue = this . state . values [ i ] . __getValue ( ) ;
228
+ if ( value !== currentValue && this . props . animateTransitions ) {
229
+ this . _setCurrentValueAnimated ( value , i ) ;
230
+ } else {
231
+ this . _setCurrentValue ( value , i ) ;
232
+ }
233
+ } ) ;
234
+ } ) ;
235
+ }
236
+
237
+ // Check for other prop changes that might require state updates, e.g., trackMarks
238
+ if ( this . props . trackMarks !== prevProps . trackMarks ) {
239
+ const newTrackMarksValues = normalizeValue ( this . props , this . props . trackMarks ) ;
240
+
241
+ this . setState ( {
242
+ trackMarksValues : updateValues ( {
243
+ values : this . state . trackMarksValues ,
244
+ newValues : newTrackMarksValues ,
245
+ } ) ,
246
+ } ) ;
247
+ }
233
248
}
234
249
235
250
_getRawValues (
@@ -685,14 +700,6 @@ export class Slider extends PureComponent<SliderProps, SliderState> {
685
700
valueVisibleStyle . opacity = 0 ;
686
701
}
687
702
688
- const interpolatedRawValues = this . _getRawValues (
689
- interpolatedTrackValues ,
690
- ) ;
691
- const minRawValue = Math . min ( ...interpolatedRawValues ) ;
692
- const minThumbValue = new Animated . Value ( minRawValue ) ;
693
- const maxRawValue = Math . max ( ...interpolatedRawValues ) ;
694
- const maxThumbValue = new Animated . Value ( maxRawValue ) ;
695
-
696
703
const _value = values [ 0 ] . __getValue ( ) ;
697
704
const sliderWidthCoefficient =
698
705
containerSize . width /
0 commit comments