@@ -91,25 +91,25 @@ const [state, setState] = useState({
9191import { addDays } from ' date-fns' ;
9292import { 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
131131import { addDays , format , isWeekend } from ' date-fns' ;
132132import { 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
147147function 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