Skip to content

Commit 7a95428

Browse files
authored
fix: correct usage of customHeaderCount to keep arrows on any monthsShown prop
1 parent 6f0da37 commit 7a95428

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

docs-site/src/examples/renderCustomHeaderTwoMonths.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
() => {
22
const [startDate, setStartDate] = useState(new Date());
3+
const monthsShown = useMemo(() => 2, []);
34
return (
45
<DatePicker
56
renderCustomHeader={({
@@ -14,7 +15,7 @@
1415
className={
1516
"react-datepicker__navigation react-datepicker__navigation--previous"
1617
}
17-
style={customHeaderCount === 1 ? { visibility: "hidden" } : null}
18+
style={{ visibility: customHeaderCount === 0 ? 'visible' : 'hidden' }}
1819
onClick={decreaseMonth}
1920
>
2021
<span
@@ -36,7 +37,7 @@
3637
className={
3738
"react-datepicker__navigation react-datepicker__navigation--next"
3839
}
39-
style={customHeaderCount === 0 ? { visibility: "hidden" } : null}
40+
style={{ visibility: customHeaderCount === monthsShown - 1 ? 'visible' : 'hidden' }}
4041
onClick={increaseMonth}
4142
>
4243
<span
@@ -51,7 +52,7 @@
5152
)}
5253
selected={startDate}
5354
onChange={(date) => setStartDate(date)}
54-
monthsShown={2}
55+
monthsShown={monthsShown}
5556
/>
5657
);
5758
};

0 commit comments

Comments
 (0)