Building your calendar
react-datepicker
main goal is to let you control how you want your date picker to look & fill.
This means you need to render the element like the days grid, years selector and next/previous month buttons.
Lets start with creating a new component file and calling the useCalendar
hook, currently only getting it's displayedMonths
and register
variables. We will also render our initial days grid.
What's going on here?
displayedMonths
will always hold the months that should be visible to the user.register
is a function that returns all the props you need for the connection of your UI - the day component with theuseCalendar
hook. It exposes stuff likeonChange
, ARIA attributes and more.Each
Month
holds few parameters, but for the beginning we are using the days array which includesDay
object, and we render it on the screen.The wrapper
div
is a grid, which is a standard way of calendar UI structure, but you can definitely try to render what you want!
Last updated