goenning
goenning
SSolidJS
Created by goenning on 2/13/2023 in #support
how to use useParams inside a ContextProvider
I have something like this
return (
<Router>
<MyContextProvider>
<Routes>
<Route path="/" ...
<Route path="/posts/:slug" ...
return (
<Router>
<MyContextProvider>
<Routes>
<Route path="/" ...
<Route path="/posts/:slug" ...
and I want to access the slug on MyContextProvider on inital page load. useParams seems to always return an empty object 😦
5 replies
SSolidJS
Created by goenning on 12/14/2022 in #support
Looks like solid-router doesn't like encoded forward slashes as params?
I have a route path like /app/:name/view and then the name might actually contain a forward slash, so i encode it with encodeURIComponent, but solid-router doesn't route it correct, it goes straight to 404.
4 replies
SSolidJS
Created by goenning on 12/7/2022 in #support
reactive initialValue on createResource
is it possible to make initialValue react based on a signal? I have this:
const [namespaces] = createResource(contexts, fetchNamespaces, {
initialValue: getCachedNamespaces(contexts()),
});
const [namespaces] = createResource(contexts, fetchNamespaces, {
initialValue: getCachedNamespaces(contexts()),
});
Whenever the list of contexts change, it'll refetch the namespaces for that contexts. But the initialValue does not as it's evaluated once on render. I want to build sort of a cache, so whenever the context changes, the list of namespaces will be whatever is cached (localstorage) and then it'll refresh shortly after.
12 replies