@@ -14,7 +14,6 @@ import {clamp, snapValueToStep, useControlledState} from '@react-stately/utils';
14
14
import { NumberFieldProps } from '@react-types/numberfield' ;
15
15
import { NumberFormatter , NumberParser } from '@internationalized/number' ;
16
16
import { useCallback , useMemo , useRef , useState } from 'react' ;
17
- import { useLayoutEffect } from '@react-aria/utils' ;
18
17
19
18
export interface NumberFieldState {
20
19
/**
@@ -105,9 +104,15 @@ export function useNumberFieldState(
105
104
// Update the input value when the number value or format options change. This is done
106
105
// in a useEffect so that the controlled behavior is correct and we only update the
107
106
// textfield after prop changes.
108
- useLayoutEffect ( ( ) => {
107
+ let prevValue = useRef ( numberValue ) ;
108
+ let prevLocale = useRef ( locale ) ;
109
+ let prevFormatOptions = useRef ( formatOptions ) ;
110
+ if ( ! Object . is ( numberValue , prevValue . current ) || locale !== prevLocale . current || formatOptions !== prevFormatOptions . current ) {
109
111
setInputValue ( format ( numberValue ) ) ;
110
- } , [ numberValue , locale , formatOptions ] ) ;
112
+ prevValue . current = numberValue ;
113
+ prevLocale . current = locale ;
114
+ prevFormatOptions . current = formatOptions ;
115
+ }
111
116
112
117
// Store last parsed value in a ref so it can be used by increment/decrement below
113
118
let parsedValue = useMemo ( ( ) => numberParser . parse ( inputValue ) , [ numberParser , inputValue ] ) ;
0 commit comments