diff --git a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts index d8d02d6ee7d2..12c8b00617d5 100644 --- a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts +++ b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts @@ -174,22 +174,10 @@ export const usePickerValue = < const { current: defaultValue } = React.useRef(inDefaultValue); const { current: isControlled } = React.useRef(inValueWithoutRenderTimezone !== undefined); - const { - timezone, - value: inValueWithTimezoneToRender, - handleValueChange, - } = useValueWithTimezone({ - timezone: timezoneProp, - value: inValueWithoutRenderTimezone, - defaultValue, - onChange, - valueManager, - }); - /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */ if (process.env.NODE_ENV !== 'production') { React.useEffect(() => { - if (isControlled !== (inValueWithTimezoneToRender !== undefined)) { + if (isControlled !== (inValueWithoutRenderTimezone !== undefined)) { console.error( [ `MUI X: A component is changing the ${ @@ -203,7 +191,7 @@ export const usePickerValue = < ].join('\n'), ); } - }, [inValueWithTimezoneToRender]); + }, [inValueWithoutRenderTimezone]); React.useEffect(() => { if (!isControlled && defaultValue !== inDefaultValue) { @@ -220,9 +208,20 @@ export const usePickerValue = < const utils = useUtils(); const adapter = useLocalizationContext(); - const { isOpen, setIsOpen } = useOpenState(props); + const { + timezone, + value: inValueWithTimezoneToRender, + handleValueChange, + } = useValueWithTimezone({ + timezone: timezoneProp, + value: inValueWithoutRenderTimezone, + defaultValue, + onChange, + valueManager, + }); + const [dateState, setDateState] = React.useState>(() => { let initialValue: TValue; if (inValueWithTimezoneToRender !== undefined) {