Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Jun 14, 2024
1 parent f188a4c commit dfb0623
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ${
Expand All @@ -203,7 +191,7 @@ export const usePickerValue = <
].join('\n'),
);
}
}, [inValueWithTimezoneToRender]);
}, [inValueWithoutRenderTimezone]);

React.useEffect(() => {
if (!isControlled && defaultValue !== inDefaultValue) {
Expand All @@ -220,9 +208,20 @@ export const usePickerValue = <

const utils = useUtils<TDate>();
const adapter = useLocalizationContext<TDate>();

const { isOpen, setIsOpen } = useOpenState(props);

const {
timezone,
value: inValueWithTimezoneToRender,
handleValueChange,
} = useValueWithTimezone({
timezone: timezoneProp,
value: inValueWithoutRenderTimezone,
defaultValue,
onChange,
valueManager,
});

const [dateState, setDateState] = React.useState<UsePickerValueState<TValue>>(() => {
let initialValue: TValue;
if (inValueWithTimezoneToRender !== undefined) {
Expand Down

0 comments on commit dfb0623

Please sign in to comment.