Mutations without sending data to the server? #2790
-
After downloading data (say a JSON object) via RTK Query, if we want users to be able to modify that data locally, and then confirm before updating the server with the mutated data, is the best practice to use RTK Query mutation, or to duplicate it in a separate, local-only (non-RTK-Query) Redux store, and then perform a server mutation via RTK when it's ready? I'd kind of hate to duplicate it, because it's already in the store (albeit in a less directly-accessible way), but this temporary "WIP" state is necessary (i.e. without being uploaded). I couldn't find anything obvious after some searching & reading the docs, but I'm guessing someone's encountered a case like this, any thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I'd definitely keep local WIP data separately if I personally was doing it, yeah. That's basically what I did wayyyy back in 2016 on my first Redux project, and later wrote about in a tutorial post: That keeps a clear separation between "this is the data that matches what's on the server", and "here's what the user is currently editing". |
Beta Was this translation helpful? Give feedback.
-
In this situation, do you recommend using |
Beta Was this translation helpful? Give feedback.
I'd definitely keep local WIP data separately if I personally was doing it, yeah. That's basically what I did wayyyy back in 2016 on my first Redux project, and later wrote about in a tutorial post:
That keeps a clear separation between "this is the data that matches what's on the server", and "here's what the user is currently editing".