huntabyte / shadcn-svelte

shadcn/ui, but for Svelte. ✨
https://next.shadcn-svelte.com
MIT License
5.55k stars 341 forks source link

[bug] Cannot read properties of undefined (state, isMobile) #1454

Closed hhamja closed 2 weeks ago

hhamja commented 3 weeks ago

Describe the bug

I added the sidebar of shadcn, which was newly released in svelte5 version, and added the code according to the usage instructions. It says that all status values ​​defined for the sidebar cannot refer to properties.

Reproduction

I added the sidebar of shadcn, which was newly released in svelte5 version, and added the code according to the usage instructions. It says that all status values ​​defined for the sidebar cannot refer to properties.

Logs

TypeError: Cannot read properties of undefined (reading 'state')
    at _layout (/Users/gimminseog/hacking/mundi-mvp/src/routes/+layout.svelte:8:10)
    at Root (/Users/gimminseog/hacking/mundi-mvp/.svelte-kit/generated/root.svelte:65:3)
    at Module.render (/Users/gimminseog/hacking/mundi-mvp/node_modules/.pnpm/svelte@5.1.9/node_modules/svelte/src/internal/server/index.js:117:2)
    at Function._render [as render] (/Users/gimminseog/hacking/mundi-mvp/node_modules/.pnpm/svelte@5.1.9/node_modules/svelte/src/legacy/legacy-server.js:27:18)
    at Module.render_response (/Users/gimminseog/hacking/mundi-mvp/node_modules/.pnpm/@sveltejs+kit@2.7.5_@sveltejs+vite-plugin-svelte@4.0.0_svelte@5.1.9_vite@5.4.10_@types+node@2_n73cut2ozdmfw5oaoigy64bexq/node_modules/@sveltejs/kit/src/runtime/server/page/render.js:171:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.respond_with_error (/Users/gimminseog/hacking/mundi-mvp/node_modules/.pnpm/@sveltejs+kit@2.7.5_@sveltejs+vite-plugin-svelte@4.0.0_svelte@5.1.9_vite@5.4.10_@types+node@2_n73cut2ozdmfw5oaoigy64bexq/node_modules/@sveltejs/kit/src/runtime/server/page/respond_with_error.js:85:10)
    at async resolve (/Users/gimminseog/hacking/mundi-mvp/node_modules/.pnpm/@sveltejs+kit@2.7.5_@sveltejs+vite-plugin-svelte@4.0.0_svelte@5.1.9_vite@5.4.10_@types+node@2_n73cut2ozdmfw5oaoigy64bexq/node_modules/@sveltejs/kit/src/runtime/server/respond.js:524:12)
    at async Module.respond (/Users/gimminseog/hacking/mundi-mvp/node_modules/.pnpm/@sveltejs+kit@2.7.5_@sveltejs+vite-plugin-svelte@4.0.0_svelte@5.1.9_vite@5.4.10_@types+node@2_n73cut2ozdmfw5oaoigy64bexq/node_modules/@sveltejs/kit/src/runtime/server/respond.js:327:20)
    at async file:///Users/gimminseog/hacking/mundi-mvp/node_modules/.pnpm/@sveltejs+kit@2.7.5_@sveltejs+vite-plugin-svelte@4.0.0_svelte@5.1.9_vite@5.4.10_@types+node@2_n73cut2ozdmfw5oaoigy64bexq/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:524:22

System Info

Mac os M3

Severity

annoyance

ieedan commented 3 weeks ago

Can you provide a minimal reproduction? This isn't quite enough information to troubleshoot.

nikolaydyankov commented 3 weeks ago

Did you forget <Sidebar.Provider> perhaps?

huntabyte commented 3 weeks ago

As @nikolaydyankov said, seems likely that it's missing the provider with those errors.

dangelomedinag commented 3 weeks ago

I got the same error and after a few minutes of tracking down where the problem was, I just needed to update bits-ui to version @next

bun i bits-ui@next

I did the installation in a new project following the documentation

bunx shadcn-svelte@next init

and there the version was installed bits-ui@0.21.16

huntabyte commented 3 weeks ago

That's likely because bun is an inferior package manager to pnpm