Browse Source

chore: remove redundant state (#38208)

Co-authored-by: xingming <xingjiang.gxj@antgroup.com>
pull/38214/head
行冥 2 years ago
committed by GitHub
parent
commit
3390290c26
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      components/date-picker/demo/select-in-range.md

6
components/date-picker/demo/select-in-range.md

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

Loading…
Cancel
Save