diff --git a/.changeset/forty-buses-act.md b/.changeset/forty-buses-act.md new file mode 100644 index 0000000000..b1558b7ec7 --- /dev/null +++ b/.changeset/forty-buses-act.md @@ -0,0 +1,5 @@ +--- +'@td-design/react-native-picker': patch +--- + +fix: 修复删除日期后自动设置当前日期的bug diff --git a/packages/react-native-picker/src/date-picker/useDatePicker.ts b/packages/react-native-picker/src/date-picker/useDatePicker.ts index 3af3216039..5e1094cf40 100644 --- a/packages/react-native-picker/src/date-picker/useDatePicker.ts +++ b/packages/react-native-picker/src/date-picker/useDatePicker.ts @@ -12,10 +12,10 @@ export default function useDatePicker({ displayType, format, }: DatePickerPropsBase & ModalPickerProps) { - const [date, setDate] = useSafeState(value ?? new Date()); + const [date, setDate] = useSafeState(value); useEffect(() => { - setDate(value ?? new Date()); + setDate(value); }, [value]); const handleChange = (date?: Date) => { diff --git a/packages/react-native-picker/src/useDatePicker.ts b/packages/react-native-picker/src/useDatePicker.ts index bbbb8889e7..7b0f9ed096 100644 --- a/packages/react-native-picker/src/useDatePicker.ts +++ b/packages/react-native-picker/src/useDatePicker.ts @@ -38,7 +38,7 @@ export default function useDatePicker({ }); useEffect(() => { - setDate(value ?? new Date()); + setDate(value); }, [value]); const handlePress = () => {