Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 3a6ca4e

Browse files
committed
hotfix demo not working
1 parent d43dc01 commit 3a6ca4e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/components/DateRangePicker/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,25 @@ const [state, setState] = useState({
9191
import { addDays } from 'date-fns';
9292
import { useState } from 'react';
9393

94-
const [state, setState] = useState([
95-
{
94+
const [state, setState] = useState({
95+
selection1: {
9696
startDate: addDays(new Date(), -6),
9797
endDate: new Date(),
9898
key: 'selection1'
9999
},
100-
{
100+
selection2: {
101101
startDate: addDays(new Date(), 1),
102102
endDate: addDays(new Date(), 7),
103103
key: 'selection2'
104104
}
105-
]);
105+
});
106106

107107
<DateRangePicker
108-
onChange={item => setState([item.selection])}
108+
onChange={item => setState({ ...state, ...item })}
109109
showSelectionPreview={true}
110110
moveRangeOnFirstSelection={false}
111111
months={2}
112-
ranges={state}
112+
ranges={[state.selection1, state.selection2]}
113113
direction="horizontal"
114114
ariaLabels={{
115115
dateInput: {
@@ -131,18 +131,18 @@ Show orange dot only for weekend
131131
import { addDays, format, isWeekend } from 'date-fns';
132132
import { useState } from 'react';
133133

134-
const [state, setState] = useState([
135-
{
134+
const [state, setState] = useState({
135+
selection1: {
136136
startDate: addDays(new Date(), -6),
137137
endDate: new Date(),
138138
key: 'selection1'
139139
},
140-
{
140+
selection2: {
141141
startDate: addDays(new Date(), 1),
142142
endDate: addDays(new Date(), 7),
143143
key: 'selection2'
144144
}
145-
]);
145+
});
146146

147147
function customDayContent(day) {
148148
extraDot = null;
@@ -170,11 +170,11 @@ function customDayContent(day) {
170170
}
171171

172172
<DateRangePicker
173-
onChange={item => setState([item.selection])}
173+
onChange={item => setState({ ...state, ...item })}
174174
showSelectionPreview={true}
175175
moveRangeOnFirstSelection={false}
176176
months={2}
177-
ranges={state}
177+
ranges={[state.selection1, state.selection2]}
178178
direction="horizontal"
179179
dayContentRenderer={customDayContent}
180180
ariaLabels={{

0 commit comments

Comments
 (0)