simonwep / selection

✨ Viselect - A high performance and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies, super small. Support for major frameworks!
https://simonwep.github.io/selection
MIT License
2.71k stars 149 forks source link

TypeError: n.__ is not a function when rendering the Component #221

Closed t-schlarb closed 7 months ago

t-schlarb commented 11 months ago

We currently use the @viselect/preact": "^3.0.0 without any issues. After an upgrade to the latest @viselect/preact": "^3.5.0 Version, we do get the following error during the rendering process of the component:

flushAfterPaintEffects (http://localhost:5173/node_modules/preact/hooks/src/index.js#424) TypeError: n.__ is not a function

The Error can be reproduced with the following dependencies:

{ "private": true, "type": "module", "scripts": { "dev": "vite", "build": "vite build", "preview": "vite preview" }, "dependencies": { "@preact/signals": "^1.2.2", "@viselect/preact": "^3.5.0", "chart.js": "^4.4.1", "dexie": "^3.2.4", "preact": "^10.19.3", "preact-iso": "^2.3.2", "preact-render-to-string": "^6.3.1", "primeicons": "^6.0.1", "primereact": "^10.3.1" }, "devDependencies": { "@preact/preset-vite": "^2.8.1", "eslint": "^8.52.0", "eslint-config-preact": "^1.3.0", "typescript": "^5.3.3", "vite": "^5.0.11" } }

simonwep commented 10 months ago

This looks like a bug in preact to me? Since the error is not in any file that corresponds to this package?

t-schlarb commented 10 months ago

Hi Simon,

thank you for your response. After some further debugging, there seems to be an exception everytime a javascript event is triggered within the SelectionArea. If, for instance, i try to select something within the SelectionArea, the following exception is thrown within the useState- Hook of the SelectionArea Component (Currently using node v18.19.0):

Screenshot 2024-01-17 142128

SelectionArea.tsx:26 Uncaught (in promise) TypeError: Te is not a function or its return value is not iterable at b.Ke [as constructor] (SelectionArea.tsx:26:15) at b.O [as render] (index.js:608:14) at L (index.js:220:14) at C (children.js:86:3) at j (index.js:487:4) at L (index.js:292:19) at C (children.js:86:3) at L (index.js:242:4) at x (component.js:135:3) at debounceRendering.js:13:7

simonwep commented 10 months ago

Can you reproduce that on the demos or create a codesandbox?

t-schlarb commented 10 months ago

Hi Simon,

I tried to reproduce it with your existing sample in codesandbox. I forked your existing demo, and just changed the version within the package.json (from @viselect/preact": "3.0.0" to @viselect/preact": "^3.5.0":

https://codesandbox.io/p/sandbox/viselect-preact-forked-xvrh2d

I also made another forked project by just changing the package.json to the same dependencies that we are currently using within our project. This package.json has a more recent dependency tree:

https://codesandbox.io/p/sandbox/viselect-preact-forked-5jx6hk

In both samples, the selection event does trigger an exception.

I hope this information helps.

Regards, Thomas