The slice object returned from createSlice includes each of the individual case reducer functions you passed in as slice.caseReducers, to help with situations like this.
So, you could do:
addModule(state, action) {
const { moduleName, renderingData } = action.payload;
if (!state.modules[moduleName]) {
state.modules[moduleName] = renderingData;
}
WorkspacesSlice.caseReducers.setActiveModule(state, action);
},
Also, reducer functions have no this, because there are no class instances involved. They’re just functions.