Skip to content

Commit

Permalink
Merge pull request #915 from thundersdata-frontend/rn-issue
Browse files Browse the repository at this point in the history
fix: 修复日期组件的bug
  • Loading branch information
chj-damon authored Oct 24, 2024
2 parents f777eb7 + f5b4deb commit 669c56d
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 669c56d

Please sign in to comment.