#Server action outside of form loading state

5 messages · Page 1 of 1 (latest)

severe geode
#

I am wondering how I can get the loading state for my server action to use in other parts of my application.

I have a business partner select dropdown in my header which is part of my layout which is a client component. The select is not inside a form

In my header I want to call my server action when another businesspartner is selected in the dropdown. The server action that does some api calls and other things to switch businesspartner and at the end I will call revalidateTag to revalidate customer data

Now I want to get the loading state from the server action and user that state in my layout and other places inside my app.

Is there any way to get the loading state form the server action and also use it in other components?

eager dockBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

ember furnace
severe geode
ember furnace
#

hmm you have to implement it yourself then. make a global context and whenever you run an action, set that global state