To use the eachYearOfInterval function from date-fns library, follow these steps:
index.tsx21 chars2 lines
eachYearOfInterval function from date-fnsindex.tsx105 chars4 lines
eachYearOfInterval functionindex.tsx170 chars8 lines
The eachYearOfInterval function returns an array of each year between the start and end date passed in as an object with start and end properties. In the example above, it returns [ 2020, 2021 ].
You can now use the eachYearOfInterval function to get an array of years for any given date interval range.
gistlibby LogSnag