TaQuanMinhLong
TaQuanMinhLong
SSolidJS
Created by TaQuanMinhLong on 12/12/2023 in #support
Reanimation
hey, is it possible in solidjs to remount a component to make the animation happen again after the signal is being updated?
2 replies
SSolidJS
Created by TaQuanMinhLong on 12/8/2023 in #support
solid router's Data API
I'm a little bit confused about createAsync with the load function In the example of the GitHub repo, there's a cache fn to fetch data
const getUser = cache((id) => {
return (await fetch(`/api/users${id}`)).json()
}, "users")
const getUser = cache((id) => {
return (await fetch(`/api/users${id}`)).json()
}, "users")
Then we attached it to the load function of the Route
import { lazy } from "solid-js";
import { Route } from "@solidjs/router";
import { getUser } from ... // the cache function

const User = lazy(() => import("./pages/users/[id].js"));

// load function
function loadUser({params, location}) {
void getUser(params.id)
}

// Pass it in the route definition
<Route path="/users/:id" component={User} load={loadUser} />;
import { lazy } from "solid-js";
import { Route } from "@solidjs/router";
import { getUser } from ... // the cache function

const User = lazy(() => import("./pages/users/[id].js"));

// load function
function loadUser({params, location}) {
void getUser(params.id)
}

// Pass it in the route definition
<Route path="/users/:id" component={User} load={loadUser} />;
Then in the current route component, we have to again attach the fetch function to the create async
// pages/users/[id].js
import { getUser } from ... // the cache function

export default function User(props) {
const user = createAsync(() => getUser(props.params.id));
return <h1>{user().name}</h1>;
}
// pages/users/[id].js
import { getUser } from ... // the cache function

export default function User(props) {
const user = createAsync(() => getUser(props.params.id));
return <h1>{user().name}</h1>;
}
Then why can't we just attach to the create async only? Why are we attaching the function to both Route's load fn and create async? This kinda confused me
15 replies
SSolidJS
Created by TaQuanMinhLong on 3/15/2023 in #support
Loading data into context
Hi what's the best practice to load data from server (like using prisma) into the context? i did try some method like using createServerData$ but seems like only if I call the getter function inside the JSX Element, then the fetcher will work, other wise it won't, the data.state is just pending, won't beready
2 replies