Skip to content

Instantly share code, notes, and snippets.

@romgrk
romgrk / patch-redux-toolkit.ts
Last active January 27, 2025 03:10
redux-toolkit reducers without immer
import { AnyAction, Slice } from '@reduxjs/toolkit'
/* The redux-toolkit maintainers refuse to add a way to disable immer.js for
* specific reducers, therefore we need to create an escape hatch by ourselves.
* Immer.js needs to be disabled in certain cases for performance reasons.
* Link: https://github.com/reduxjs/redux-toolkit/issues/242
*/
/** Add reducers without immer.js to a redux-toolkit slice */
export function addRawReducers<S>(