Skip to content

Commit

Permalink
adding month toggle value to useEffect hook
Browse files Browse the repository at this point in the history
  • Loading branch information
dpitcock committed Feb 10, 2025
1 parent ee506de commit b1ebdf9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pages/date-picker/simple.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ export default function DateInputScenario() {
const { urlParams, setUrlParams } = useContext(AppContext as DatePickerDemoContext);
const monthOnly = urlParams.monthOnly ?? dateRangePickerDemoDefaults.monthOnly;
const hasValue = urlParams.hasValue ?? dateRangePickerDemoDefaults.hasValue;
const initValue = '2025-02-14';

const [value, setValue] = useState<DatePickerProps['value']>('');

useEffect(() => {
const initValue = monthOnly ? '2025-02' : '2025-02-00';
if (hasValue) {
setValue(initValue);
} else {
setValue('');
}
}, [hasValue]);
}, [hasValue, monthOnly]);

return (
<Box padding="s">
Expand Down

0 comments on commit b1ebdf9

Please sign in to comment.