Answer the question
In order to leave comments, you need to log in
Next js + redux how to check in static props so as not to make unnecessary requests?
Hello, I use next in conjunction with redax, and there was such a question. When switching to pages, I make requests in order to fill the store with the data that is needed for the operation of this page. When navigating between pages, I already have the cart state on the glob store and don't need to drag it again. But here the question is how to do it, I need something like.
export const getStaticProps = wrapper.getStaticProps(async ({ store }) => {
if (isEmpty(store.getState().cart)) await store.dispatch(getCart());
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question