Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs-site/src/components/Example/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef, useState } from "react";
import React, { forwardRef, useMemo, useState } from "react";
import { LiveProvider, LiveEditor, LiveError, LivePreview } from "react-live";
import DatePicker, {
registerLocale,
Expand Down Expand Up @@ -35,6 +35,7 @@ export default class CodeExampleComponent extends React.Component {
scope={{
// NB any globals added here should also be referenced in ../../examples/.eslintrc
useState,
useMemo,
DatePicker,
CalendarContainer,
...DateFNS,
Expand Down
20 changes: 14 additions & 6 deletions docs-site/src/examples/renderCustomHeaderTwoMonths.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useState, useMemo } from "react";

() => {
const [selectedDate, setSelectedDate] = useState(new Date());
const [startDate, setStartDate] = useState(new Date());
const monthsShown = useMemo(() => 2, []);
return (
<DatePicker
renderCustomHeader={({
Expand All @@ -14,8 +17,10 @@
className={
"react-datepicker__navigation react-datepicker__navigation--previous"
}
style={customHeaderCount === 1 ? { visibility: "hidden" } : null}
onClick={decreaseMonth}
style={{
visibility: customHeaderCount === 0 ? "visible" : "hidden",
}}
>
<span
className={
Expand All @@ -36,8 +41,11 @@
className={
"react-datepicker__navigation react-datepicker__navigation--next"
}
style={customHeaderCount === 0 ? { visibility: "hidden" } : null}
onClick={increaseMonth}
style={{
visibility:
customHeaderCount === monthsShown - 1 ? "visible" : "hidden",
}}
>
<span
className={
Expand All @@ -49,9 +57,9 @@
</button>
</div>
)}
selected={selectedDate}
onChange={(date) => setSelectedDate(date)}
monthsShown={2}
selected={startDate}
onChange={(date) => setStartDate(date)}
monthsShown={monthsShown}
/>
);
};
Loading