-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
docs: root state type with TypeScript and configureStore #326
Conversation
Deploy preview for redux-starter-kit-docs ready! Built with commit 1334799 https://deploy-preview-326--redux-starter-kit-docs.netlify.com |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ea5396c:
|
The info is just a bit off. The problem comes when you don't define the root reducer explicitly, and instead pass the slice reducers to const store = configureStore({
reducer: {
first: firstReducer,
second: secondReducer,
}
}); There's no Can you tweak the wording and example to match that? |
I am going to familiarize myself a bit more with the material before I continue with this PR. I thought I knew a lot about the Redux Starter Kit / Toolkit already, but today showed that it still had a few surprises for me. |
Sure, and thanks for putting the PR together! |
I just updated the PR, taking this feedback into account:
|
Co-authored-by: Lenz Weber <mail@lenzw.de>
When passing the root reducers directly to
configureStore()
, it is not possible to get the root state type directly from the reducers. For the type, you will then have to accessstore.getState()
instead.So, instead of
type RootState = ReturnType<typeof rootReducer>
you will have to usetype RootState = ReturnType<typeof store.getState>
. This PR adds this little piece of information.