How to import date-fns properly? #1819
-
I'm having some difficulty implementing the date-fns library. When I try and import date-fns only, I get the following error: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Please provide a complete code snippet that causes the error and the library version. |
Beta Was this translation helpful? Give feedback.
-
That was the code of the tutorial I was following to try and create a calendar |
Beta Was this translation helpful? Give feedback.
-
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' |
Beta Was this translation helpful? Give feedback.
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:
...or import them from the root package: