Samual 🦢
Samual 🦢
SSolidJS
Created by Samual 🦢 on 9/19/2024 in #support
modern equivalent of `createRouteData()`
okay so I've simplified it to
const dummyCacheThing = cache(async () => 1, "dummyCacheThing")

const [ routeData ] = createResource(() => {
dummyCacheThing()
return /* route data here */
}, v => v)

// logged on route change and form submissions
createEffect(() => console.log(routeData()))
const dummyCacheThing = cache(async () => 1, "dummyCacheThing")

const [ routeData ] = createResource(() => {
dummyCacheThing()
return /* route data here */
}, v => v)

// logged on route change and form submissions
createEffect(() => console.log(routeData()))
but I'm not too sure why this works. and why does commenting out the dummyCacheThing() line stop it from working?
11 replies
SSolidJS
Created by Samual 🦢 on 9/19/2024 in #support
modern equivalent of `createRouteData()`
nah don't worry I think it was user error
11 replies
SSolidJS
Created by Samual 🦢 on 9/19/2024 in #support
modern equivalent of `createRouteData()`
yeah once again, I don't want to be directly referencing specific resources either for the same reason stated above
11 replies
SSolidJS
Created by Samual 🦢 on 9/19/2024 in #support
modern equivalent of `createRouteData()`
also please can you link the docs page for useSubmission(), I can't seem to find it
11 replies
SSolidJS
Created by Samual 🦢 on 9/19/2024 in #support
modern equivalent of `createRouteData()`
and it's not out of laziness. referencing actions directly means I can't write code that can be used generically throughout my app
11 replies
SSolidJS
Created by Samual 🦢 on 9/19/2024 in #support
modern equivalent of `createRouteData()`
I don't want to be directly referencing actions
11 replies
SSolidJS
Created by KamehamehaNudel on 1/31/2024 in #support
Escape Suspense when using resources?
I had to do this to avoid suspense for a specific resource:
const [ foo ] = createResource(
() => {
// ...
},
async bar => {
// ...
}
)

const getFoo = createMemo(() => foo.loading ? undefined : foo())
const [ foo ] = createResource(
() => {
// ...
},
async bar => {
// ...
}
)

const getFoo = createMemo(() => foo.loading ? undefined : foo())
and then use getFoo() instead of foo directly
18 replies
SSolidJS
Created by Samual 🦢 on 1/17/2024 in #support
how do you get a route to respond with an http header?
I've figured it out getRequestEvent()?.node.res.appendHeader("x-foo", "bar")
6 replies
SSolidJS
Created by Samual 🦢 on 1/17/2024 in #support
how do you get a route to respond with an http header?
setting a cookie
6 replies
SSolidJS
Created by Samual 🦢 on 1/17/2024 in #support
how do you get a route to respond with an http header?
nope, a regular route
6 replies
SSolidJS
Created by Samual 🦢 on 1/9/2024 in #support
use server get cookie
thank you
3 replies
SSolidJS
Created by Samual 🦢 on 10/27/2023 in #support
mark module or just variable as secret to stop being bundled into client
I'm guessing there isn't
3 replies
SSolidJS
Created by Samual 🦢 on 10/27/2023 in #support
mark module or just variable as secret to stop being bundled into client
if there isn't just say
3 replies
SSolidJS
Created by Samual 🦢 on 9/7/2023 in #support
set response header from within `createServerData$()` callback
ty
8 replies
SSolidJS
Created by Samual 🦢 on 9/7/2023 in #support
set response header from within `createServerData$()` callback
8 replies
SSolidJS
Created by Samual 🦢 on 9/7/2023 in #support
set response header from within `createServerData$()` callback
that only fixes initial server render though for when the resource is invalidated and the client side router is fetching the data again useRequest().responseHeaders is undefined even at the beginning of the callback
8 replies
SSolidJS
Created by Samual 🦢 on 9/7/2023 in #support
set response header from within `createServerData$()` callback
okay I figured it out, useRequest().responseHeaders is defined at the beginning of the callback but as soon as the callback awaits something, it becomes undefined but if you save a reference to it to a variable making changes still works even after an await so the lesson is always have useRequest() at the top of a function if you plan on using it
createServerData$(async () => {
const { responseHeaders } = useRequest()
const result = await somethingAsync()

responseHeaders.set("x-foo", "bar")

return result
})
createServerData$(async () => {
const { responseHeaders } = useRequest()
const result = await somethingAsync()

responseHeaders.set("x-foo", "bar")

return result
})
8 replies
SSolidJS
Created by Samual 🦢 on 9/7/2023 in #support
set response header from within `createServerData$()` callback
what does that achieve? when trying to help people please test your proposed solution
8 replies
SSolidJS
Created by Samual 🦢 on 8/31/2023 in #support
input elements become empty upon hydration
okay it turned out to be my fault, I didn't realise I was replacing the whole page during hydration
4 replies
SSolidJS
Created by Samual 🦢 on 8/15/2023 in #support
how do you set attributes on `<Html>` and `<Body>` from within a route?
are you talking about using reactivity to update the attributes? I can already do that without context, but it won't help this needs to happen on the server and none of the reactive primitives do anything server side
6 replies