problems getting useActionData to run on the client #2289
Unanswered
fergusmeiklejohn
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm in two minds about whether this is better as an issue or a discussion so I thought start here to see what you all think.
I'm using a JS library called Uppy to upload an image. Why use a library? Because it comes with a great UI for cropping and resizing the image.
The problem is that if I point it to a route action, the upload works perfectly and the action returns data but the client doesn't respond.
Use case is like this:
Uppy sends image to action, image sent to (eg) Cloudinary, Uppy gets a 200 response and closes. The action writes to the DB. Action flashes the session to trigger a toast message and returns (eg) {success: true}. The root loader is listening for toast session messages, it picks up the flashed message, returns it in the loaderData. The client doesn't respond!
A console.log in the client component will show the actionData on the server logs but the client console shows nothing.
Quick example here adapting the Remix file uploader: https://github.com/fergusmeiklejohn/file-and-cloudinary-upload
What do we all think? Is this a bug or a feature request? I think my expectation is that an action is like an API endpoint, but it's not working in that way in this instance. I can solve this partially by picking up the response header which is returned to Uppy and triggering a function in the client but I feel like we need a solution to this problem that doesn't send us back to client side routing and error handling.
Beta Was this translation helpful? Give feedback.
All reactions