-
I'm using next.js and RTK Query together. It works well when accessing url directly, but there was a problem when moving the browser back or forward. What is the cause of this problem?? example code // getInitialProps
MyApp.getInitialProps = wrapper.getInitialAppProps((store) => async (context) => {
...
// initialize data from getInitialProps
await store.dispatch(fetchMyInfo.initiate(1, { forceRefetch: true })).unwrap();
...
}) // getServerSideProps
export const getServerSideProps = wrapper.getServerSideProps((store) => async (context) => {
const { userNo } = context.query;
...
// Recall after changing argument
await store.dispatch(fetchMyInfo.initiate(userNo , { forceRefetch: true })).unwrap();
...
}); Thank you for your reply. :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I have to admit, from the description I don't really understand what problem you are describing here, I'm sorry. Could you maybe explain that in more detail? Generally: when getInitialProps or getServerSideProps are executed is a next.js thing, we can't really influence that. |
Beta Was this translation helpful? Give feedback.
I have to admit, from the description I don't really understand what problem you are describing here, I'm sorry. Could you maybe explain that in more detail?
Generally: when getInitialProps or getServerSideProps are executed is a next.js thing, we can't really influence that.
I don't think you need the forceRefetch here (this will always be executed with a new empty store on the server) and you probably also don't need the unwrap (you only need that to access the result after the call, but here you're just prefilling the cache?).