Open sudravi opened 4 years ago
That's what it seems like to me. You will need to call the show()
method via refs. For example:
import React from 'react';
import MonthPicker from 'react-month-picker';
const Example = () => {
const [yearMonth, setYearMonth] = React.useState({ year: 2020, month: 9 });
const monthPickerRef = React.useRef<MonthPicker>(null);
const showPicker = () => {
if (monthPickerRef && monthPickerRef.current) {
monthPickerRef.current.show();
}
};
const handlePickerChange = (year: number, month: number) => {
setYearMonth({ year, month });
};
return (
<MonthPicker
ref={monthPickerRef}
value={yearMonth}
onChange={handlePickerChange}
>
<span onClick={showPicker}>
{yearMonth.month} {yearMonth.year}
</span>
</MonthPicker>
);
};
In the Code Sandbox link below, if you set react-month-picker version greater than or equal to 2.0.1, show prop doesn't work anymore.
https://codesandbox.io/s/holy-lake-636cb?file=/src/index.js