Having an issue while attempting to create an asynchronous produce with immer. When calling the async function, this error is encountered:
Below is my code snippet:
import { combineReducers, createStore } from 'redux';
import produce from 'immer';
const mainReducer = produce(async (draft, { type, payload }: { type: string; payload: any }) => {
switch (type) {
case 'foo': {
draft = await myAsyncFn(payload);
}
}
});
const reducers = {
main: mainReducer,
};
const rootReducer = combineReducers(reducers);
export const mainStore = createStore(rootReducer);
The output shows the following error message:
Error: [Immer] produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '[object Promise]'
Question arising - why doesn't it work despite the assumption of its possibility as per this reference link: ?
What does the term
classes that are marked with '[immerable]
entail exactly?