duk
duk
SSolidJS
Created by Luka on 6/8/2024 in #support
How to handle Loading/Error
if you are using createAsync (I suppose with cache) you should use Suspense and ErrorBoundary to handle loading and error states, because createAsync only turns a Promise into a Signal, it doesn't offer the ResourceReturn type like createResource.
2 replies
SSolidJS
Created by Shiba Bop on 6/8/2024 in #support
access event.locals from a server function
Have you tried getRequestEvent() ?
import { getRequestEvent } from "solid-js/web"

const getUsers = cache(async () => {
'use server';
const event = getRequestEvent()
console.log(event.locals)
...
}, 'users');
import { getRequestEvent } from "solid-js/web"

const getUsers = cache(async () => {
'use server';
const event = getRequestEvent()
console.log(event.locals)
...
}, 'users');
7 replies
SSolidJS
Created by -=Camille=- on 5/10/2024 in #support
Component that can render a different tag depending on prop?
You could also use document.createElement(props.as) and return that from your component if you don't need it to be dynamic. In Solid DOM and JSX nodes are interchangable.
14 replies
SSolidJS
Created by Some Call Me Tim on 4/13/2024 in #support
Getting the full domain/url server side
I don't know your exact setup but I think the rest of the path should be available through the router like useLocation
11 replies
SSolidJS
Created by FjordWarden on 4/13/2024 in #support
No Context when using hyper dom expressions
Glad to help
4 replies
SSolidJS
Created by Some Call Me Tim on 4/13/2024 in #support
Getting the full domain/url server side
Server side you can try getRequestEvent and checking if the Host header is forwarded with the request
import { getRequestEvent } from "solid-js/web";
const event = getRequestEvent();
if (event) {
const domain = event.request.headers.get("Host")
}
import { getRequestEvent } from "solid-js/web";
const event = getRequestEvent();
if (event) {
const domain = event.request.headers.get("Host")
}
https://docs.solidjs.com/reference/server-utilities/get-request-event
11 replies
SSolidJS
Created by FjordWarden on 4/13/2024 in #support
No Context when using hyper dom expressions
Hi, don't know if you've already solved the error but I updated your solidjs/h version to match solidjs 1.8.16 in the importmap and replaced
props.children
props.children
with
() => props.children
() => props.children
in
CounterProvider
CounterProvider
which seems to fix it. Here is your updated codepen: https://codepen.io/davidivkovic/pen/MWRBJeR
4 replies