S
SolidJS15mo ago
dmayo2

[solved] createEffect signal is Undefined

I can't seem to figure out why the signal user is not updating (the output near Profile). The signal does get populated. Clues? Tutorial link with real-world example? Thanks.
35 Replies
dmayo2
dmayo215mo ago
Might be createResource? Not quite. Suspense?
Alex Lohr
Alex Lohr15mo ago
user is directly used in the return statement, right after profile. Suspense would help if you used createResource to take the supabase call into solid's reactive system. user() initially returns []
dmayo2
dmayo215mo ago
Thanks. Isn't that what the const currentUser is doing? The return of supabase is put into setUser(data). I thought that was "bringing the supabase call into solid's reactive system". I'm obviously missing something in my thought process. I also tried createResource with and without <Suspense and with and without <Show
dmayo2
dmayo215mo ago
This is close. In the browser console it says Unrecognized value. Skipped inserting > Object and the object is the data that's returned, but the output next to the <h2>Profile is still not rendered, not even the Loading... (or maybe it's so fast I don't see it).
dmayo2
dmayo215mo ago
Well, loading is spelled wrong. Upon fixing that, I do see the Loading... appear for a second or two, then it goes away, and replaced by an empty string. So, if the output of the Resource Signal is just currentUser() the page will render, and the Loading... flashes, but no output. If I try currentUser().user.email the page won't render as that throws an error of currentUser() is undefined Getting closer, just missing something.
dmayo2
dmayo215mo ago
Ok, this works, but I need to target one node, not the entire data stream
dmayo2
dmayo215mo ago
REEEEE
REEEEE15mo ago
You would do currentUser()?.user.email or in a Show
<Show when={currentUser()} fallback={<> Loading... </>}>
<> Profile | {currentUser()!.user.email} </>
</Show>
<Show when={currentUser()} fallback={<> Loading... </>}>
<> Profile | {currentUser()!.user.email} </>
</Show>
dmayo2
dmayo215mo ago
Thanks. Still getting currentUser() undefined
REEEEE
REEEEE15mo ago
How are you using it?
dmayo2
dmayo215mo ago
Many trials and errors.
dmayo2
dmayo215mo ago
I'm having a serious brain fart. I can the entire object to print out, but I can't seem to just extract the email value. This shot is with JSON.stringify on the await function.
REEEEE
REEEEE15mo ago
how are you using currentUser() in the JSX?
dmayo2
dmayo215mo ago
currently (iteration #3,456)
REEEEE
REEEEE15mo ago
you need to call currentUser in the Show same with the effect
dmayo2
dmayo215mo ago
I cleaned it up. As is, it's still outputting the entire object.
REEEEE
REEEEE15mo ago
This did not work?
dmayo2
dmayo215mo ago
no, it's killing me.
REEEEE
REEEEE15mo ago
it's outputting the entire object because you're not accessing anything from the object.
<> {currentUser()?.user.email} </>
<> {currentUser()?.user.email} </>
dmayo2
dmayo215mo ago
true. but that's been my iterations-- dot notation, brackets, etc. I can't seem to target just the email: data:user:email
REEEEE
REEEEE15mo ago
<> {currentUser()?.data.user.email} </>
<> {currentUser()?.data.user.email} </>
Didn't notice there was a data object
dmayo2
dmayo215mo ago
REEEEE
REEEEE15mo ago
and change the when to when={currentUser()}
dmayo2
dmayo215mo ago
REEEEE
REEEEE15mo ago
you're also returning a string from fetchUser not an object remove JSON.stringify
dmayo2
dmayo215mo ago
Can I buy you a beer.
REEEEE
REEEEE15mo ago
haha
dmayo2
dmayo215mo ago
I don't think I've ever seen the ? before after the()
REEEEE
REEEEE15mo ago
It's a typescript thing Called optional chaining
dmayo2
dmayo215mo ago
I'm specifically using the js version when I installed with npm
REEEEE
REEEEE15mo ago
Well technically you don't need it in this case the solution wasn't because of the ?
dmayo2
dmayo215mo ago
It's 5pm somewhere. Thank you very much.
REEEEE
REEEEE15mo ago
No problem
thiccaxe
thiccaxe15mo ago
Not in typescript, it is in JavaScript. Related !. is typescript for disabling nullish checking
REEEEE
REEEEE15mo ago
Ah thank you for correcting me Mixed it up
Want results from more Discord servers?
Add your server
More Posts
Hydration fails with start-cloudflare-pagesFor some reason, all the `data-hk` attributes in the SSR-generated page have a single number (e.g. `client-side solid-router prepends every relative link with hash, even when not desiredI am using hashIntegration with the solid-router for an SPA running on our site - but the entire siPassing signal from one template's function to a different template functionI've been reading so much I think I've confused myself more. If I `createSignal()` in `header.jsx` hMonorepo error with SolidStart `__vite_ssr_import_0__.template is not a function`I've got a shared UI library (compiled into esm + cjs with vite) that is used with both a regular Soundefined context for dynamically added componentHi team, I am coding a toast component. The idea is to expose a `success` method via context. UsersDo we have an ExtractProps helper?Finally have a need for this, but managed to avoid it till now. lolProperty 'pathLength' does not exist on type 'CircleSVGAttributes<SVGCircleElement>'I was trying setting the `pathLength` property but I get the TS error above, not sure if the properEvents (oninput on keyup) stopped working?I just asked in the solid-start channel but this may be a bigger issue than that. I may have done soHow to add calculated getter in a existing store?`const [store, setStore] = createStore({firstName: "Foo", lastName: "Bar"})`using createResource on nodeI am trying to create a `filesystem` primitive that abstracts different file systems (virtual on loc