You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been struggling for days with an issue getting the sidebar component to work in my svelte 5 project.
I have been following the implementation from https://next.shadcn-svelte.com/docs/components/sidebar to perfection, even tried to mimic some of the dependencies (versions) used in the next branch in this repository, but to no avail.
I am getting the follow error for the component:
[Error [CompileError]: src/lib/components/shadcn/ui/sidebar/context.svelte.ts:6:16 $derived.by(...) can only be used as a variable declaration initializer or a class field
https://svelte.dev/e/state_invalid_placement] {
id: 'src/lib/components/shadcn/ui/sidebar/context.svelte.ts',
frame: ' 4 | class SidebarState {\n' +
' 5 | constructor(props) {\n' +
' 6 | this.open = $derived.by(() => this.props.open());\n' +
' ^\n' +
' 7 | this.openMobile = $state(false);\n' +
' 8 | this.state = $derived.by(() => this.open ? "expanded" : "collapsed");',
code: 'state_invalid_placement',
I'm interested to know if anyone else has experienced this issue, and perhaps managed to solve it?
If it helps, these are my dependencies, where I have updated vite to newest version along with bits-ui as I assumed those could be the culprit.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have been struggling for days with an issue getting the sidebar component to work in my svelte 5 project.
I have been following the implementation from https://next.shadcn-svelte.com/docs/components/sidebar to perfection, even tried to mimic some of the dependencies (versions) used in the next branch in this repository, but to no avail.
I am getting the follow error for the component:
I'm interested to know if anyone else has experienced this issue, and perhaps managed to solve it?
If it helps, these are my dependencies, where I have updated vite to newest version along with bits-ui as I assumed those could be the culprit.
devDependencies:
`
`
Beta Was this translation helpful? Give feedback.
All reactions