Closed kramduckner closed 2 years ago
Just throwing this out there but instead of going the redux path with thunk, we could use a much less verbose and seamless integration with NextJS using stale while revalidate hook (https://swr.vercel.app/)
I am not familiar with redux tookit, but my immediate thought was that incorporating useQuery hook when fetching data could be a good solution. useQuery will have the language state variable as a dependency, meaning that it will trigger a new request automatically when the language state changes - So selecting a new language will trigger a new GET request to the API with the updated query parameter (language).
How will these solutions work with our redux state? I'm game for whatever, just don't want a bunch of different patterns in there and want to make sure we're not negating any of the benefits of using redux!
Just saw that you we're possibly migrating to next.js? If that's happening, I say do whatevers best practice within that context.
I also think react-query would work well if we don't switch to nextjs. If we do switch, I agree with @kramduckner but I am not very familiar with the best practices. Also, I don't mind removing the redux logic altogether as I think useState and Context API should suffice.
I agree about removing the redux logic. Imo it might be a bit overkill and can potensially slow down the development process as less developers are comfortable with it. The priority should be to get the most important information out as fast as possible. If needed we can probably spend some time re-implementing it after we've got the most important parts to production.
Since we're using redux toolkit, might be a good idea to use the async thunks https://redux-toolkit.js.org/api/createAsyncThunk that come with the library.