Skip to content

RTK: preloaded state and type inferring from store? #3368

Answered by EskiMojo14
dakur asked this question in Q&A
Discussion options

You must be logged in to vote
export type RootState = ReturnType<typeof slice.reducer>;
export const configure = (preloadedState?: RootState) => {
  const store = configureStore({
    preloadedState,
    reducer: slice.reducer,
  })
  return store;
}
export type AppStore = ReturnType<typeof configure>;
export type AppDispatch = AppStore["dispatch"]

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dakur
Comment options

@EskiMojo14
Comment options

Answer selected by EskiMojo14
@dakur
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants