Skip to content

Commit

Permalink
fix: 修复日期组件的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chj-damon committed Oct 24, 2024
1 parent 8a3e964 commit f5b4deb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-jokes-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/react-native-picker': patch
---

fix: 修复日期组件的bug
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function useDatePicker<T>({
const minDayjs = useMemo(() => dayjs(minDate), [minDate]);
const maxDayjs = useMemo(() => dayjs(maxDate), [maxDate]);

const [tempValue, setTempValue] = useSafeState(value);
const [tempValue, setTempValue] = useSafeState(value ?? new Date());

const clipDate = (date: Date) => {
if (mode === 'datetime') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default function useDatePicker({
};

const handleOk = () => {
onChange?.(date, dayjs(date).format(format));
const value = date ?? new Date();
onChange?.(value, dayjs(value).format(format));
onClose?.();
};

Expand Down

0 comments on commit f5b4deb

Please sign in to comment.