Property 'payload' does not exist on type 'Action<"__NEXT_REDUX_WRAPPER_HYDRATE__">' with latest Redux-Toolkit 1.9.0
See original GitHub issueDescribe the bug
RTK team redesigned extraReducers
a bit and current approach is going to be deprecated when RTK 2.0 releases. So current implementation
extraReducers: {
[HYDRATE]: (state, action) => {
// ...
},
},
should be changed to:
extraReducers: (builder) => {
builder.addCase(HYDRATE, (state, action) => {
// ...
}),
},
But currently going that way is not possible due to the following error:
Property ‘payload’ does not exist on type ‘Action<“NEXT_REDUX_WRAPPER_HYDRATE”>’
Apparently there is no payload
on action
variable, only type
is present.
To Reproduce
Steps to reproduce the behavior:
Screenshots
Issue Analytics
- State:
- Created 10 months ago
- Reactions:5
- Comments:6
Top Results From Across the Web
angular - Property 'payload' does not exist on type 'Action ...
The payload property has been removed from the Action interface. However, the example they give seems completely counter intuitive (in my view..
Read more >Property Payload does not exist on type... #31 - GitHub
Interesting is that it seems to take the type from the first action (which indeed does not have a payload constructor). Here is...
Read more >Usage With TypeScript - Redux Toolkit
This will result in the created action being of type PayloadActionCreator<number, string> . In some setups, you will need a literal type for ......
Read more >react-redux-typescript-guide/typesafe-actions - Gitter
Hi, is there a way of extracting the type of an action's payload, for use in generics? I'm trying to type the function...
Read more >Error A case reducer on a non-draftable value must not return ...
But my action.payload is well defined and redux toolkit is up to date. ... "property 'assign' does not exist on type 'ObjectConstructor'".
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is not a
next-redux-wrapper
issue.As per RTK documentation (as linked to in the deprecation warning): https://redux-toolkit.js.org/api/createSlice#the-extrareducers-builder-callback-notation
You should use the the builder callback notation.
This means you should first create a typed action with the HYDRATE string const. In this way you are forced to type the payload of your action.
See below example for what your updated code should look like:
You can also create an action to be shared among slices, like this:
and instead import that into your slices.
give us a reproduction link describe for this issue