Plugins: how extend only one instance of dayjs?
See original GitHub issueI’m evaluating this library for react-day-picker and I have a concern about plugins.
For what I understand, extending dayjs with plugins will affect all the instances of dayjs.
E.g. if I extend dayjs with weekOfYear plugin, the dayjs instances used by an application implementing react-day-picker+dayjs will be extended too. Is it correct? If yes, how to extend just one instance of dayjs?
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
The Complete Guide to Day.js - Mirza Leka - Medium
Custom Parse Format extends dayjs() the constructor to support custom formats of input strings. Basically, it allows us to pass the date format ......
Read more >How to use the dayjs.extend function in dayjs
To help you get started, we've selected a few dayjs examples, based on popular ways it is used in public projects. ; "dayjs";...
Read more >Plugin
A plugin is an independent module that can be added to Day.js to extend functionality or add new features. By default, Day.js comes...
Read more >How can I export a plugin from dayjs() in Javascript?
import isToday from "dayjs/plugin/isToday"; export dayjs.extend(isToday);. javascript · reactjs · typescript · dayjs.
Read more >dayjs
Start using dayjs in your project by running `npm i dayjs`. ... A plugin is an independent module that can be added to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks @iamkun for your answer,
I don’t agree much with this design choice. Not that I expect it giving practical problems for now, but an external component using dayjs would alter how dayjs works in the whole app. This doesn’t sound correct to me. What I would have preferred is a factory like:
Just my feedback! Thanks for your work on dayjs!
Thanks. To keep only one type of dayjs might be better I think. 😊