glassy
glassy
SSolidJS
Created by glassy on 5/29/2024 in #support
createAsync vs createResource and how does Suspense work?
Hello. From doing some searches in here it looks like createAsync (+cache) seems to be the new recommended approach for data loading. I am wondering though, createResource returns a lot of information and options for the request
type ResourceReturn<T> = [
{
(): T | undefined
state: "unresolved" | "pending" | "ready" | "refreshing" | "errored"
loading: boolean
error: any
latest: T | undefined
},
{
mutate: (v: T | undefined) => T | undefined
refetch: (info: unknown) => Promise<T> | T
}
]
type ResourceReturn<T> = [
{
(): T | undefined
state: "unresolved" | "pending" | "ready" | "refreshing" | "errored"
loading: boolean
error: any
latest: T | undefined
},
{
mutate: (v: T | undefined) => T | undefined
refetch: (info: unknown) => Promise<T> | T
}
]
There is the state, the error, and options to mutate and refetch. But createAsync returns just the data. What if I want to also get the state? What if I want to mutate/refetch the data? And how should (or how can) I handle errors when using createAsync? EDIT: (Answering some of my own questions) since createAsync returns the data from createResource then it is possible to use data.loading and data.error If I use createResource instead then I won't be able to use cache. Also, I am wondering how Suspense actually works. How does it detect that some data is still loading. Is it possible to create my own resource manually that Suspense detects without using createResource?
41 replies
SSolidJS
Created by glassy on 4/28/2024 in #support
Why can't I change the path alias "~/*" to "@/*" in the tsconfig.json?
Using @/* would be easier on my keyboard. After changing it the imports work correctly in VS Code typescript, but when I run the app it complains that modules are not found. Trying to change the alias to anything else other than ~/* (eg. src/*) also doesn't work. Do I need to change it somewhere else to make it work for runtime?
10 replies
SSolidJS
Created by glassy on 4/28/2024 in #support
Does SolidStart support private folders in the routes directory?
Like described here: https://nextjs.org/docs/app/building-your-application/routing/colocation#project-organization-features Otherwise, is there a way to organize the components used for a route in a subfolder of the folder the route is in? Or is there any way to opt out a file or folder in the routes directory from the routing system?
2 replies
SSolidJS
Created by glassy on 3/5/2024 in #support
MobX + SolidJS enableExternalSource untracked bug?
I am evaluating using MobX with SolidJS and now that there is an untrack parameter to enableExternalSource I have tried putting MobX's untracked in it, but I'm running into an issue with <For> updates Please see: https://github.com/solidjs/solid/issues/1850#issuecomment-1976086047
2 replies
SSolidJS
Created by glassy on 11/25/2023 in #support
SolidStart SSR + CSR?
Beginner question: I am going to start a project that could be created as an SPA and am wondering a bit whether SolidStart would benefit me. I've used other frameworks before (Nuxt) but it's been a while and I 'm a bit confused. What I'm thinking is when first opening the app to a url in the browser, the server would render the first page for fast page load. Then afterwards if the user clicks on other urls, the client would render it on its own. Does SolidStart SSR already do that? Or does it server-side render every page?
9 replies