Get displayMonth in Footer #1687
Closed
homerchen19
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
You can get the current navigation state with the useNavigation hook: https://codesandbox.io/s/daypicker-footer-with-usenavigation-xixfd6?file=/src/App.tsx import React from "react";
import { DayPicker, useNavigation } from "react-day-picker";
import "react-day-picker/dist/style.css";
function Footer() {
const { currentMonth, displayMonths } = useNavigation();
return <span>{currentMonth.toLocaleDateString()}</span>;
}
export default function App() {
const [selectedDay, setSelectedDay] = React.useState<Date | undefined>();
return (
<DayPicker
components={{ Footer }}
mode="single"
onSelect={setSelectedDay}
selected={selectedDay}
/>
);
} I agree however in a next version would work better pass this as props too. |
Beta Was this translation helpful? Give feedback.
2 replies
-
@homerchen19 from v8.6.0 you can start using the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I noticed some components like
Caption
,Day
can accessdisplayMonth
from their props. I wonder if we can also access it from theFooter
component and thefooter
prop. Thank you.Beta Was this translation helpful? Give feedback.
All reactions