Missing AppStore from file
MarcHbb opened this issue · 1 comments
MarcHbb commented
What docs page needs to be fixed?
- Section: Code Quality
- Page: Usage with TypeScript
What is the problem?
When explaining how to type hooks, you import a type that doesn't exist :
import { useDispatch, useSelector, useStore } from 'react-redux'
import type { AppDispatch, AppStore, RootState } from './store'. <===== AppStore doesn't exist in ./store
// Use throughout your app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
export const useAppSelector = useSelector.withTypes<RootState>()
export const useAppStore = useStore.withTypes<AppStore>()
This is the store file as you wrote it at the beginning of the section :
import { configureStore } from '@reduxjs/toolkit'
// ...
export const store = configureStore({
reducer: {
posts: postsReducer,
comments: commentsReducer,
users: usersReducer
}
})
// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch
There's no mention of AppStore
in this file, thus you import it in the hook file
What should be changed to fix the problem?
EskiMojo14 commented
raised #4704 to fix, thanks!