Skip to content

How to import date-fns properly? #1819

Answered by kossnocorp
nihalkurki asked this question in General
Discussion options

You must be logged in to vote

That's not the definition of "the same" 😂 When you debug, such "small" details make all the difference.

You should either import functions as default:

import addMonths from 'date-fns/addMonths'
import subMonths from 'date-fns/subMonths'
import startOfWeek from 'date-fns/startOfWeek'
import endOfWeek from 'date-fns/endOfWeek'
// ...

...or import them from the root package:

import { addMonths, subMonths, startOfWeek, endOfWeek } from 'date-fns'

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@kossnocorp
Comment options

@nihalkurki
Comment options

Comment options

You must be logged in to vote
4 replies
@nihalkurki
Comment options

@nihalkurki
Comment options

@kossnocorp
Comment options

@totymedli
Comment options

Answer selected by kossnocorp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants