[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
Might be
createResource?
Not quite. Suspense?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 []
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 <ShowThis 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).
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.Ok, this works, but I need to target one node, not the entire data stream


You would do
currentUser()?.user.email or in a Show
Thanks. Still getting
currentUser() undefinedHow are you using it?
Many trials and errors.
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.

how are you using
currentUser() in the JSX?currently (iteration #3,456)

you need to call
currentUser in the Show
same with the effectI cleaned it up. As is, it's still outputting the entire object.

This did not work?
no, it's killing me.

it's outputting the entire object because you're not accessing anything from the object.
true. but that's been my iterations-- dot notation, brackets, etc. I can't seem to target just the email:
data:user:email
Didn't notice there was a
data object
and change the when to
when={currentUser()}
you're also returning a string from
fetchUser not an object
remove JSON.stringifyCan I buy you a beer.
haha
I don't think I've ever seen the
? before after the()It's a typescript thing
Called optional chaining
I'm specifically using the js version when I installed with npm
Well technically you don't need it in this case
the solution wasn't because of the
?It's 5pm somewhere. Thank you very much.
No problem
Not in typescript, it is in JavaScript.
Related
!. is typescript for disabling nullish checkingAh thank you for correcting me
Mixed it up