Skip to content

Commit

Permalink
Merge pull request #904 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 8, 2024
2 parents 1840475 + 2e1c360 commit d2b7267
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-buses-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/react-native-picker': patch
---

fix: 修复删除日期后自动设置当前日期的bug
4 changes: 2 additions & 2 deletions packages/react-native-picker/src/date-picker/useDatePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export default function useDatePicker({
displayType,
format,
}: DatePickerPropsBase & ModalPickerProps) {
const [date, setDate] = useSafeState<Date | undefined>(value ?? new Date());
const [date, setDate] = useSafeState<Date | undefined>(value);

useEffect(() => {
setDate(value ?? new Date());
setDate(value);
}, [value]);

const handleChange = (date?: Date) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-picker/src/useDatePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function useDatePicker({
});

useEffect(() => {
setDate(value ?? new Date());
setDate(value);
}, [value]);

const handlePress = () => {
Expand Down

0 comments on commit d2b7267

Please sign in to comment.