Closed MarcHbb closed 3 weeks ago
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
AppStore
raised #4704 to fix, thanks!
What docs page needs to be fixed?
What is the problem?
When explaining how to type hooks, you import a type that doesn't exist :
This is the store file as you wrote it at the beginning of the section :
There's no mention of
AppStore
in this file, thus you import it in the hook fileWhat should be changed to fix the problem?