react-anchorme icon indicating copy to clipboard operation
react-anchorme copied to clipboard

TypeError: t.list is not a function

Open Ninfa-Jeon opened this issue 7 months ago • 1 comments

With the latest update and support for React v19, this library breaks with the following error: TypeError: t.list is not a function This happens whenever tests are run with happy-dom environment.

In fact, I tried running your own tests from the Anchorme.test.tsx file and they failed with the same error. The error is thrown in the <Anchorme/> component.

Image

I have verified that this error does not occur with the previous version 4.0.1 of react-anchorme. This issue is not because of incompatibility with React as downgrading it does not solve it.

When I change the test environment to jsdom, this error goes away but due to preferences I cannot switch to jsdom and it is a bummer because the previous version worked fine with happy-dom.

I suspect this has something to do with the way react-anchorme is being bundled because I have also tried writing a test for anchorme while it was still a transitive dependency through react-anchorme and my test environment was able to access the .list() without errors hinting that the issue is not within anchorme but rather the way it is bundled within react-anchorme.

Ninfa-Jeon avatar Jul 07 '25 13:07 Ninfa-Jeon

I have been testing this locally and encountered the same problem. It seems that the CJS build of react-anchorme isn't correctly handling default exports from anchorme and react. Dropping a debugger on the error shows the import for anchorme resolving to { default: ... }, instead of correctly importing the library. Hopefully a tweak to react-anchorme's bundler config can fix this.

andogq avatar Jul 08 '25 03:07 andogq