#Store Jotaii

1 messages · Page 1 of 1 (latest)

desert valley
ionic mapleBOT
#

Hi @desert valley. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

desert valley
#

Thank you for helping, I understand a bit better now

ionic mapleBOT
#

Sorry @desert valley, I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

rich locust
#

your welcome

desert valley
#

So I’m trying to figure this out, your help would be appreciated, I’m essentially putting Jotai in a client component and wrapping it around my server. Does that mean my server component temporarily becomes a client component just the get values in the provider? Meaning I can now import from a client component into that server component it’s wrapped in? I think I get the concept, I just don’t understand how to actually implement this

rich locust
#

The server component does not become a client component

#

The server component is just a child of the client component

desert valley
#

Makes sense, and I’m assuming because it’s a child of the client component, that allows me to import things from the client?

#

Without getting an error?

desert valley
#

Sorry for 20 questions it’s just the beta docs are kinda sparse and I’m tryna figure it out

#

I’m in deep with project I’ve been working on it’s and such a hack job

rich locust
#

You can import client components into server components fine,

only when you want to import a server component into a client compontent it needs to be passed as a prop/child

desert valley
#

sorry i mixed it up. basically i want to pass in a server function as a prop to a client component so that when i hit the button it runs the server component

desert valley
#

Basically Im using the cloud convert api and that can only be run on the server because the user agent has to be node. Im trying to make a client component that can trigger the conversion to happen on the server, then give me the info back in my client component

#

I know I can pass in props to get the result, but I can’t figure out how to trigger it to run on the server

#

The only thing I can think of is doing an API route, but I can’t get live updates

rich locust
#

So you can’t really pass a function from a server component to a client component as far as I’m aware

#

I can’t check either since I’m not home

desert valley
#

So I tried some experimenting and I think it got it to work. Maybe lol. What I did was import a server function “use server” to a client component “use client” and ran it with await

#

I’m assuming it’s running the function as a promise or something idk, kinda like an API call

#

I can’t return any data from it into the client component, but it does trigger on the server

#

So I could just do that and pass the results down as a prop

#

Other than that, I think the only other way to do what I want is to make an API route or something

#

Needs further testing but long story short if you import a server only function you have to await it