chore: remove redundant state (#38208)

Co-authored-by: xingming <xingjiang.gxj@antgroup.com>
This commit is contained in:
行冥 2022-10-25 23:24:18 +08:00 committed by GitHub
parent ca97b05661
commit 3390290c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,6 @@ type RangeValue = [Moment | null, Moment | null] | null;
const App: React.FC = () => { const App: React.FC = () => {
const [dates, setDates] = useState<RangeValue>(null); const [dates, setDates] = useState<RangeValue>(null);
const [hackValue, setHackValue] = useState<RangeValue>(null);
const [value, setValue] = useState<RangeValue>(null); const [value, setValue] = useState<RangeValue>(null);
const disabledDate = (current: Moment) => { const disabledDate = (current: Moment) => {
@ -38,16 +37,15 @@ const App: React.FC = () => {
const onOpenChange = (open: boolean) => { const onOpenChange = (open: boolean) => {
if (open) { if (open) {
setHackValue([null, null]);
setDates([null, null]); setDates([null, null]);
} else { } else {
setHackValue(null); setDates(null);
} }
}; };
return ( return (
<RangePicker <RangePicker
value={hackValue || value} value={dates || value}
disabledDate={disabledDate} disabledDate={disabledDate}
onCalendarChange={val => setDates(val)} onCalendarChange={val => setDates(val)}
onChange={val => setValue(val)} onChange={val => setValue(val)}