Skip to content

Focus of custom caption is lost #1502

Answered by gpbl
linor-shtutman asked this question in Support
Discussion options

You must be logged in to vote

Thanks! I understand the docs for the custom components is not clear :) Adding better docs in #1501.

I see in the code above that the type of the returned function (passed to components: { Caption }) is not correct. I haven't investigated why this causes the DayPicker to render nothing :)

A better approach to the custom component is to pass the component function straight to the components prop. See how the useNavigation hook can be used here to navigate between the months:

https://codesandbox.io/s/react-day-picker-8-forked-bqkeo9?file=/src/App.tsx

import React from 'react';

import { format } from 'date-fns';
import { CaptionProps, DayPicker, useNavigation } from 'react-day-picker';

fun…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by gpbl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Documentation only changes
3 participants
Converted from issue

This discussion was converted from issue #1486 on August 11, 2022 22:09.