local-storage: TypeError: Class constructor CustomEvent cannot be invoked without 'new'
When running tests with Jest & running our app on "@rehooks/local-storage": "2.4.1"
Details:
at new LocalStorageChanged (node_modules/@rehooks/local-storage/src/local-storage-events.ts:21:9)
at Object.writeStorage (node_modules/@rehooks/local-storage/src/local-storage-events.ts:54:30)
at create (node_modules/@rehooks/local-storage/src/use-localstorage.ts:89:7)
at apply (node_modules/react-dom/cjs/react-dom.development.js:23487:20)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:3945:14)
at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:315:27)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:266:3)
at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:212:11)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:144:23)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 44
- Comments: 25 (3 by maintainers)
Commits related to this issue
- FOLIO-3128 lock @rehooks/local-storage to 2.4.0 Modules that use `PersistedPaneset` are broken due to bugs in the release of `@rehooks/local-storage` `2.4.1`. Additional details at https://github.com... — committed to folio-org/platform-complete by zburke 3 years ago
- STSMACOM-501 avoid @rehooks/local-storage 2.4.1 Lock onto `2.4.0` to avoid https://github.com/rehooks/local-storage/issues/77 Refs STSMACOM-501 — committed to folio-org/stripes-smart-components by zburke 3 years ago
- STSMACOM-501 avoid @rehooks/local-storage 2.4.1 (#1046) Lock onto `2.4.0` to avoid https://github.com/rehooks/local-storage/issues/77 Refs STSMACOM-501 — committed to folio-org/stripes-smart-components by zburke 3 years ago
- STSMACOM-501 avoid @rehooks/local-storage 2.4.1 (#1046) Lock onto `2.4.0` to avoid https://github.com/rehooks/local-storage/issues/77 Refs STSMACOM-501 — committed to folio-org/stripes-smart-components by zburke 3 years ago
- Revert rehooks/local-storage back to 2.4.0 See https://github.com/rehooks/local-storage/issues/77 — committed to betagouv/mon-entreprise by johangirod 3 years ago
- Revert rehooks/local-storage back to 2.4.0 See https://github.com/rehooks/local-storage/issues/77 — committed to betagouv/mon-entreprise by johangirod 3 years ago
I am having the same issue. For a quickfix you can rollback to 2.4.0. The breaking behavior was introduced by #67. I think the fix would be to implement the suggestion in this comment: https://github.com/rehooks/local-storage/pull/67#issuecomment-668833477
Reopening as it seems the issue is not resolved
When is that planned to be fixed? 2.4.1 is broken
I do get the same error with 2.4.3, reverting back to 2.4.0 works
I am still seeing this error after upgrading to 2.4.3. Is there anything else that needs to be done to fix this?
While I wait on getting access to publish to npmjs.com, I have published the 2.4.2 patch to GitHub packages instead, and have also published it under my own scope. Here is how you may use both alternatives:
Switch to @jharrilim/local-storage
Probably the simplest choice, just change your package.json entry that once said:
to:
Use the GitHub package
A little more effort, but if it matters, it keeps you pulling from the same org. Add a
.npmrcfile to your repo if you don’t already have one, and ensure it has this line in it:I can confirm that our CI started failing when we updated from 2.4.0 to 2.4.1.
@jharrilim the fix is released under 2.4.3 version on npm. I don’t have org access to rehooks to add you as a contributor to npm. Didn’t focus on this, as I was busy with my day job and don’t really use this package anymore. Thanks for keeping it maintained. I’ll try to be more active with publishing.
Do we have some plans to update the version on the npm?
Thanks for suggesting the quickfix!
I haven’t taken a look at this repo in a while so I might be a bit slow to boot, but I shall look into this tonight or sometime this week.
Agreed, and sorry for the inconvenience. We shall fix this sometime soon.
@spencerschack you are a life saver 🥇