export const store: AppStore = configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: false,
immutableCheck: false
}).concat([
createStateSyncMiddleware({
channel: "ketchcloth",
broadcastChannelOption: { type: "localstorage", webWorkerSupport: false },
blacklist: ['persist/PERSIST', 'persist/PURGE', 'persist/REHYDRATE']
})
])
})
Here, I got the error
TS2322: Type ‘(getDefaultMiddleware: GetDefaultMiddleware) => Tuple<[ThunkMiddleware<any, UnknownAction>, …Middleware<{}, any, Dispatch>[]]>’ is not assignable to type ‘(getDefaultMiddleware: GetDefaultMiddleware) => Tuple<Middlewares>’.
Type ‘Tuple<[ThunkMiddleware<any, UnknownAction>, …Middleware<{}, any, Dispatch>[]]>’ is not assignable to type ‘Tuple<Middlewares>’.
Type ‘[ThunkMiddleware<any, UnknownAction>, …Middleware<{}, any, Dispatch>[]]’ is not assignable to type ‘Middlewares’.
Type ‘ThunkMiddleware<any, UnknownAction> | Middleware<{}, any, Dispatch>’ is not assignable to type ‘Middleware<{}, any, Dispatch>’.
Type ‘ThunkMiddleware<any, UnknownAction>’ is not assignable to type ‘Middleware<{}, any, Dispatch>’.
Types of parameters ‘next’ and ‘next’ are incompatible.
Type ‘unknown’ is not assignable to type ‘T’.
‘T’ could be instantiated with an arbitrary type which could be unrelated to ‘unknown’.
48 | export const store: AppStore = configureStore({
49 | reducer: rootReducer,
50 | middleware: (getDefaultMiddleware) =>
| ^^^^^^^^^^
51 | getDefaultMiddleware({
52 | serializableCheck: false,
53 | immutableCheck: false
I have tried enhancers(getDefaultEnhancers)
but I didn’t get any proper solution for this specific code.
2
Answers
You are passing an array to the
getDefaultMiddleware.concat
method when you should just pass the middleware(s) directly.Or spread the array into
.concat
if it’s still really what you want to use.This is the correct way to implement/configure the React Redux store in the React JS application. You can read more about React Redux from its official documentation. And redux-state-sync documentation. This redux-state-sync – plugin is not updated for 2 years. Might be it does not support the least Redux version.
Option 1:
Option 2: