Home > Mobile >  Redux toolkit typescript type issue with next js and next-redux-wrapper
Redux toolkit typescript type issue with next js and next-redux-wrapper

Time:01-10

StackBlitz Demo

I follow the setup of redux toolkit for next js in here. However, in the original question's tsconfig.json, compilerOptions.strict = false while mine is true. The issue I got is in store.js. If you look at the demo, when calling configureStore, the reducer has the following issue:

Type '(state: ReturnType<typeof combinedReducer>, action: AnyAction) => any' is not assignable to type 'Reducer<CombinedState<{ counter: CounterState; kanyeQuote: KanyeState; }>, AnyAction> | ReducersMapObject<CombinedState<{ counter: CounterState; kanyeQuote: KanyeState; }>, AnyAction>'.

Any help is appreciated.

CodePudding user response:

You can change your reducer definition to

const reducer: typeof combinedReducer = (state, action) => {

then it will work just fine.

  •  Tags:  
  • Related