Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing AppStore from file #4703

Closed
MarcHbb opened this issue May 10, 2024 · 1 comment · Fixed by #4704
Closed

Missing AppStore from file #4703

MarcHbb opened this issue May 10, 2024 · 1 comment · Fixed by #4704

Comments

@MarcHbb
Copy link

MarcHbb commented May 10, 2024

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
Copy link
Contributor

raised #4704 to fix, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants