Skip to content

Commit d92f159

Browse files
committed
custom comp in react-multi-date-picker
1 parent 4588e80 commit d92f159

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/components/misc/MultiDatePicker.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState, useEffect } from 'react';
22
import DatePicker, { DateObject } from 'react-multi-date-picker';
3+
import TextField from '@material-ui/core/TextField';
34

45
/* Check this sandbox
56
https://codesandbox.io/s/distracted-hopper-31666?file=/src/MultiDatePicker.js:373-386 */
@@ -8,7 +9,13 @@ const MultiDatePicker = ({ inputDate }) => {
89
const [pickerDate, setPickerDate] = useState(new DateObject());
910

1011
const CustomComponent = (props) => {
11-
return <>{this.props.stringDate}</>;
12+
return (
13+
<TextField
14+
label="Select Date(s)"
15+
onClick={props.openCalendar}
16+
value={props.stringDate}
17+
/>
18+
);
1219
};
1320

1421
useEffect(() => setPickerDate(inputDate), [inputDate]);
@@ -20,9 +27,10 @@ const MultiDatePicker = ({ inputDate }) => {
2027
onChange={setPickerDate}
2128
multiple={true}
2229
style={styles.picker}
23-
// render={<CustomComponent />}
24-
minDate={inputDate}
25-
maxDate={new DateObject(inputDate).add(7, 'days')}
30+
type="custom"
31+
render={<CustomComponent />}
32+
minDate={new DateObject()} //{inputDate}
33+
maxDate={new DateObject().add(7, 'days')}
2634
/>
2735
);
2836
};

0 commit comments

Comments
 (0)