Server Action. and Redux Thunk?

What is stopping me from creating a thunk that accepts a start transition as a parameter, That executes data on the server, then dispatches the result to the client. Well, an error is thrown when you take start transition as a parameter on a non-async outer function. Thunk does not like an async outer function. But other than that, nothing's telling me it's not impossible, should I look a little deeper. I'll tell you, I was getting really close to making it work. here's what I'm currently doing and I'm looking for a better way, and I adore server actions. The ultimate pattern for SSR data handling. My workaround is a rapper around a component that needs data. I do the initial load on the server, then pass the data into the component that needs it as the initial data. Using react router, I manually refresh when items are added or deleted from the database using the server components. The order is as follows, I optimistically dispatch the delete action on an element. I use a transition to delete the element from the server using the server action. I then handle any errors that may occur and dispatch a success or failure or depending on the result. At the end, I used router refresh to tell the server it needs to reload the initially. what I would like to do I would like to be able and to define a function just like you would for thunk and an API but with server actions. This would allow me to neatly, remove most state management from my components. This would let me to centralize error handling among everything else that redux is great for. I also get the great benefit of the initial load being handled by the server. The client would only be responsible for deleting or adding new items. Anybody have a clue on how I could achieve this?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server