petyosi / react-virtuoso

The most powerful virtual list component for React
https://virtuoso.dev
MIT License
5.32k stars 306 forks source link

[BUG] Deno/Fresh: Invalid type passed to createElement(): [object Object] #1154

Closed crummy closed 4 weeks ago

crummy commented 4 weeks ago

Describe the bug

When React Virtuoso is used in a Fresh project (Deno's web framework), the following error appears during render:

Invalid type passed to createElement(): [object Object]

To Reproduce

  1. Install Deno
  2. Run deno run -A -r https://fresh.deno.dev to create a Fresh project.
    • Skip styling and skip VS code setup.
  3. Edit islands/Counter.tsx and the following line in the div: <Virtuoso style={{ height: '400px' }} totalCount={200} itemContent={index => <div>Item {index}</div>} />
  4. Run deno task start
  5. The web browser and console both report this error:
    An error occurred during route handling or page rendering.
    Error: Invalid type passed to createElement(): [object Object]
    at a.__b (https://esm.sh/stable/preact@10.22.0/denonext/debug.js:23:9)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:2611)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:2543)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:5050)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:2543)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:2543)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:5050)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:5050)

Expected behavior

The standard Fresh project appears, with a Virtuoso component.

Desktop (please complete the following information):

Additional context

I know this might be a low-priority fix (maybe this bug should be against Fresh or Deno instead?) but wanted to get this documented in case someone else runs up against this in future.

petyosi commented 4 weeks ago

Looking at the stack trace, my guess would be something related to Preact itself. I don't believe Deno can affect the client-side. You can try to bring this to the Preact repo I guess. Happy to accept a PR.

I'm closing this as it's extremely unlikely for me to engage with it, and I don't want to pile up open stuff.