Christian
Christian
SSolidJS
Created by Christian on 7/26/2024 in #support
Solid-Start vinxi/http issue with useWebRequest
Thanks for the help by the way, much appreciated
14 replies
SSolidJS
Created by Christian on 7/26/2024 in #support
Solid-Start vinxi/http issue with useWebRequest
Yeah it would avoid confusion in cases like this, but it makes sense now that you explained why.
14 replies
SSolidJS
Created by Christian on 7/26/2024 in #support
Solid-Start vinxi/http issue with useWebRequest
Ah
14 replies
SSolidJS
Created by Christian on 7/26/2024 in #support
Solid-Start vinxi/http issue with useWebRequest
If it was hoisted wouldn't it be in context still then or no?
14 replies
SSolidJS
Created by Christian on 7/26/2024 in #support
Solid-Start vinxi/http issue with useWebRequest
That did fix it, do functions not hoist to the top?
14 replies
SSolidJS
Created by Christian on 7/26/2024 in #support
Solid-Start vinxi/http issue with useWebRequest
Actually same issue persists, what's the correct way to handle this? I know it's from the use server part but how do I get the user using SSR along side a createResource, unless I should be using a different SSR fetching method? ReferenceError: Cannot access 'fetchUser' before initialization
export default function App() {
const [ user ] = createResource(fetchUser);

async function fetchUser() {
'use server';
const request = getWebRequest();

try {
return await getUser(request);
} catch (e) {
console.log(e);

return null;
}
}

return (
<>
<Suspense>
<UserProvider user={user}>
<Home />
</UserProvider>
</Suspense>
</>
);
}
export default function App() {
const [ user ] = createResource(fetchUser);

async function fetchUser() {
'use server';
const request = getWebRequest();

try {
return await getUser(request);
} catch (e) {
console.log(e);

return null;
}
}

return (
<>
<Suspense>
<UserProvider user={user}>
<Home />
</UserProvider>
</Suspense>
</>
);
}
14 replies
SSolidJS
Created by Christian on 7/26/2024 in #support
Solid-Start vinxi/http issue with useWebRequest
Interesting, I figured "use server" applied to the thing below it, thanks. Creates a new issue as it complains fetchUser now doesn't exist as it's only server-sided code but that makes sense, but I think I can just solve it by doing what you recommend by moving it outside the UserProvider component into the main app and just passing in my user via props instead to the context
14 replies
SSolidJS
Created by Christian on 12/30/2023 in #support
Route Intercepting
Thanks for the help!
10 replies
SSolidJS
Created by Christian on 12/30/2023 in #support
Route Intercepting
I come from create react app that I’ve been using since 2019 so been doing all the protective shit for a while and client side stopping, just wasnt sure if there was a way via the SSR middleware since I’m new to SSR
10 replies
SSolidJS
Created by Christian on 12/30/2023 in #support
Route Intercepting
Yeah I know.
10 replies
SSolidJS
Created by Christian on 12/30/2023 in #support
Route Intercepting
Okay so yeah it’d have to be client side prevention then mixed with middleware for initial page load for best experience
10 replies
SSolidJS
Created by Christian on 12/30/2023 in #support
Route Intercepting
Oh I see.
10 replies
SSolidJS
Created by Christian on 12/30/2023 in #support
Route Intercepting
I guess my main issue is I need a way to use middlewares as I was having issues when trying, I'm still on SolidStart 0.3.10, and not sure why when I try to use @solidjs/start/server and use defineConfig from it I get issues, obviously my backend routes are protected but wanted to prevent them from seeing the page overall. I know I could onMount and redirect and prevent content from showing, and or just check it on a createResource / server side fetching on page but seemed like jank solutions compared to doing middleware which I want to get working.
10 replies
SSolidJS
Created by Christian on 11/21/2023 in #support
Using Show with createRouteData / useRouteDat
I never considered that I needed to suspend both client and server which explains the suspense use case, thanks for that explanation
6 replies
SSolidJS
Created by Christian on 11/21/2023 in #support
Using Show with createRouteData / useRouteDat
Ahhhh that makes a whole lot more sense
6 replies
SSolidJS
Created by Birk Skyum on 11/21/2023 in #support
createResource - SSR / SPA
For anyone that stumbles across it, switching the fetching to just be in the route and using routeData and useRouteData with createResource, and using a Suspense seemed to fix it, not exactly what I wanted but I'll manage.
18 replies
SSolidJS
Created by Birk Skyum on 11/21/2023 in #support
createResource - SSR / SPA
Changing it to Show when={data()}/> seems to fix the hydration errors, but then its back to blocking the entire rendering, so then I triedShow when={!data.loading && data()}/> which has the same issue of it works on a setTimeout but not instant and causes hydration issues again
18 replies
SSolidJS
Created by Birk Skyum on 11/21/2023 in #support
createResource - SSR / SPA
No description
18 replies
SSolidJS
Created by Birk Skyum on 11/21/2023 in #support
createResource - SSR / SPA
Oh interestingly enough actually, when I remove the timeout for delaying it, I do get the hydration error back. This is with the original mock, all I changed was the fetchData function, and am now only using the createResource, so using data().data for the <For each={}>, and <Show when={!data.loading}/> Nothing else was changed, and it seems to be resolved when I just add a delay to the data fetching function, 1ms doesn't work, 500ms doesn't work, but 1s did work, so not sure what exactly is the issue. The error after I clear errors and retry seems to be alluding to the fact that <Show when={!data.loading}/> isn't working correctly or it seems to be saying it's done ahead of time, unsure, because it says cannot read properties of null (reading 'data') so when I'm doing data().data it's null, which it shouldn't hit unless data.loading is false. Changing it from <Show> to <Suspense> seems to make it work SLIGHTLY better, but it will still error every other refresh with the same issue of data() is undefined.
18 replies
SSolidJS
Created by Birk Skyum on 11/21/2023 in #support
createResource - SSR / SPA
Okay, not sure what I messed up originally but that seemed to fix it despite it not working originally.
18 replies