Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll Primitive works in SolidJS, but not Solid Start #392

Closed
deshumake opened this issue Mar 14, 2023 · 5 comments
Closed

Scroll Primitive works in SolidJS, but not Solid Start #392

deshumake opened this issue Mar 14, 2023 · 5 comments
Labels
add new content Document something that is not in docs. improve documentation Enhance existing documentation.

Comments

@deshumake
Copy link

I'm getting an error when using @solid-primitives/scroll. The error is given below
image
There was also a time when I was getting an error that said it couldn't read createScrollPosition because it was undefined, but I can't reproduce that one anymore.

This issue shows up even in a new solid start project. The line number also doesn't seem to correspond to the actual place that I wrote the code in my repo, or in the new solid project. Here is the full error, if it helps

window is not defined

Clear errors and retry
ReferenceError: window is not defined
    at Proxy.createScrollPosition (file:///C:/Users/***/node_modules/@solid-primitives/scroll/dist/server.js:23:40)
    at Home (/src/routes/index.tsx:55:47)
    at Proxy.createComponent (file:///C:/Users/***/node_modules/solid-js/dist/server.js:291:15)
    at shared.element.component.element.element [as outlet] (/node_modules/@solidjs/router/dist/routing.js:87:43)
    at get children [as children] (/node_modules/@solidjs/router/dist/components.jsx:101:22)
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:194:35
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:155:49
    at createMemo (file:///C:/Users/***/node_modules/solid-js/dist/server.js:81:9)
    at children (file:///C:/Users/***/node_modules/solid-js/dist/server.js:155:16)
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:194:14
    at createMemo (file:///C:/Users/***/node_modules/solid-js/dist/server.js:81:9)
    at provider (file:///C:/Users/***/node_modules/solid-js/dist/server.js:190:12)
    at Proxy.createComponent (file:///C:/Users/***/node_modules/solid-js/dist/server.js:291:15)
    at children (/node_modules/@solidjs/router/dist/components.jsx:98:46)
    at Show (file:///C:/Users/***/node_modules/solid-js/dist/server.js:356:68)
    at Proxy.createComponent (file:///C:/Users/***/node_modules/solid-js/dist/server.js:291:15)
    at Routes (/node_modules/@solidjs/router/dist/components.jsx:94:32)
    at Proxy.createComponent (file:///C:/Users/***/node_modules/solid-js/dist/server.js:291:15)
    at get children [as children] (/src/root.tsx:52:52)
    at get children [as children] (/node_modules/solid-start/error-boundary/ErrorBoundary.tsx:32:20)
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:398:24
    at createMemo (file:///C:/Users/***/node_modules/solid-js/dist/server.js:81:9)
    at ErrorBoundary (file:///C:/Users/***/node_modules/solid-js/dist/server.js:396:3)
    at Proxy.createComponent (file:///C:/Users/***/node_modules/solid-js/dist/server.js:291:15)
    at ErrorBoundary (/node_modules/solid-start/error-boundary/ErrorBoundary.tsx:15:32)
    at Proxy.createComponent (file:///C:/Users/***/node_modules/solid-js/dist/server.js:291:15)
    at get children [as children] (/src/root.tsx:50:48)
    at get children [as children] (file:///C:/Users/***/node_modules/solid-js/dist/server.js:592:24)
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:194:35
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:155:49
    at createMemo (file:///C:/Users/***/node_modules/solid-js/dist/server.js:81:9)
    at children (file:///C:/Users/***/node_modules/solid-js/dist/server.js:155:16)
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:194:14
    at createMemo (file:///C:/Users/***/node_modules/solid-js/dist/server.js:81:9)
    at provider (file:///C:/Users/***/node_modules/solid-js/dist/server.js:190:12)
    at createComponent (file:///C:/Users/***/node_modules/solid-js/dist/server.js:291:15)
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:589:14
    at runWithOwner (file:///C:/Users/***/node_modules/solid-js/dist/server.js:166:12)
    at runSuspense (file:///C:/Users/***/node_modules/solid-js/dist/server.js:588:12)
    at Suspense (file:///C:/Users/***/node_modules/solid-js/dist/server.js:597:15)
    at Proxy.createComponent (file:///C:/Users/***/node_modules/solid-js/dist/server.js:291:15)
    at get children [as children] (/src/root.tsx:48:44)
    at get children [as children] (/node_modules/@prpc/solid/dist/server.jsx:19:20)
    at get children [as children] (/node_modules/@tanstack/solid-query/build/source/QueryClientProvider.jsx:30:20)
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:194:35
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:155:49
    at createMemo (file:///C:/Users/***/node_modules/solid-js/dist/server.js:81:9)
    at children (file:///C:/Users/***/node_modules/solid-js/dist/server.js:155:16)
    at file:///C:/Users/***/node_modules/solid-js/dist/server.js:194:14
    at createMemo (file:///C:/Users/***/node_modules/solid-js/dist/server.js:81:9)
@deshumake
Copy link
Author

I think I found the issue thanks to the discord server. There is no reference to window in a ssr component, so the call needs to be made in onMount()

Here's what I did instead that got it to work:
image

Do you think there should be any other documentation saying to do something in this way? Maybe in the primitive page? Or is this common knowledge for most people?

@boehs
Copy link
Contributor

boehs commented Mar 15, 2023

This issue is more appropriate for the solid-primitives repository. Consider moving it there.

@deshumake
Copy link
Author

Well, I think this is just a documentation issue, because I didn't know these kinds of things needed to be in onMount(). I didn't see anything about it on the Solid Start website, and it wasn't in the primitive either. Do you think we should just update the documentation for the primitives saying that they won't work as written in Solid Start? Should we have it written in one place on the Solid Start website (Maybe it is already and I just didn't see it). Should we do both? I also am not confident that this code is the best way to use these client primitives. Does anyone know a better way to do it?

@ryansolid
Copy link
Member

Yeah we need to cover SSR fundamentals in Solid core docs I think. Right now the guide is on how to set things up, not how they work. Which implies knowledge of other SSR frameworks which isn't acceptable. I will tag this with documentation.

@ryansolid ryansolid transferred this issue from solidjs/solid-start Dec 19, 2023
@LadyBluenotes LadyBluenotes added the improve documentation Enhance existing documentation. label Jan 20, 2024
@LadyBluenotes LadyBluenotes added the add new content Document something that is not in docs. label Feb 14, 2024
@LadyBluenotes
Copy link
Member

Consolidated this into #473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add new content Document something that is not in docs. improve documentation Enhance existing documentation.
Projects
None yet
Development

No branches or pull requests

4 participants