Ajso
Ajso
SSolidJS
Created by Ajso on 10/20/2024 in #support
useParams() returns params with unknown values
I'm trying to ssr a page with a dynamic parameter, but the parameters I get on the server are unknown. They are available in the preload function. Worst part is that I think this used to work a few days ago, and now it doesn't and it seems I've broken it somehow.
interface RouteProps {
id: string
}

export const route = {
preload: ({ params }) => getSong(params.id),
} satisfies RouteDefinition


export default function Song() {
const params = useParams();

console.log('params:' + JSON.stringify(params))
const data = createAsync(() => getSong(params.id));
...
interface RouteProps {
id: string
}

export const route = {
preload: ({ params }) => getSong(params.id),
} satisfies RouteDefinition


export default function Song() {
const params = useParams();

console.log('params:' + JSON.stringify(params))
const data = createAsync(() => getSong(params.id));
...
export const getSong = cache(async (id: string) => {
'use server'
const response = await api.get<GetSongResponse>(`/songs/${id}`)
return response;
}, 'song');
export const getSong = cache(async (id: string) => {
'use server'
const response = await api.get<GetSongResponse>(`/songs/${id}`)
return response;
}, 'song');
3 replies