@reduxjs/toolkit

  • Version 1.8.3
  • Published
  • 11.8 MB
  • 4 dependencies
  • MIT license

Install

npm i @reduxjs/toolkit
yarn add @reduxjs/toolkit
pnpm add @reduxjs/toolkit

Overview

The official, opinionated, batteries-included toolset for efficient Redux development

Index

Variables

Functions

Classes

Interfaces

Type Aliases

Variables

variable addListener

const addListener: BaseActionCreator<
ListenerEntry<unknown, ThunkDispatch<unknown, unknown, AnyAction>>,
'listenerMiddleware/add',
never,
never
> &
AddListenerOverloads<
{
payload: ListenerEntry<
unknown,
ThunkDispatch<unknown, unknown, AnyAction>
>;
type: 'listenerMiddleware/add';
},
unknown,
ThunkDispatch<unknown, unknown, AnyAction>,
unknown,
unknown
>;
  • Modifiers

    • @public

variable clearAllListeners

const clearAllListeners: ActionCreatorWithoutPayload<string>;
  • Modifiers

    • @public

variable createDraftSafeSelector

const createDraftSafeSelector: any;
  • "Draft-Safe" version of reselect's createSelector: If an immer-drafted object is passed into the resulting selector's first argument, the selector will act on the current draft value, instead of returning a cached value that might be possibly outdated if the draft has been modified since.

    Modifiers

    • @public

variable removeListener

const removeListener: BaseActionCreator<
ListenerEntry<unknown, ThunkDispatch<unknown, unknown, AnyAction>>,
'listenerMiddleware/remove',
never,
never
> &
AddListenerOverloads<
{
payload: ListenerEntry<
unknown,
ThunkDispatch<unknown, unknown, AnyAction>
>;
type: 'listenerMiddleware/remove';
},
unknown,
ThunkDispatch<unknown, unknown, AnyAction>,
any,
UnsubscribeListenerOptions
>;
  • Modifiers

    • @public

Functions

function configureStore

configureStore: <
S = any,
A extends Action = AnyAction,
M extends Middlewares<S> = [ThunkMiddleware<S, AnyAction>]
>(
options: ConfigureStoreOptions<S, A, M>
) => EnhancedStore<S, A, M>;
  • A friendly abstraction over the standard Redux createStore() function.

    Parameter config

    The store configuration.

    Returns

    A configured Redux store.

    Modifiers

    • @public

function createAction

createAction: {
<P = void, T extends string = string>(type: T): PayloadActionCreator<P, T>;
<PA extends PrepareAction<any>, T extends string = string>(
type: T,
prepareAction: PA
): IfPrepareActionMethodProvided<
PA,
_ActionCreatorWithPreparedPayload<PA, T>,
IsAny<
ReturnType<PA>['payload'],
ActionCreatorWithPayload<any, T>,
IsUnknown<
ReturnType<PA>['payload'],
ActionCreatorWithNonInferrablePayload<T>,
IfVoid<
ReturnType<PA>['payload'],
ActionCreatorWithoutPayload<T>,
IfMaybeUndefined<
ReturnType<PA>['payload'],
ActionCreatorWithOptionalPayload<
ReturnType<PA>['payload'],
T
>,
ActionCreatorWithPayload<ReturnType<PA>['payload'], T>
>
>
>
>
>;
};
  • A utility function to create an action creator for the given action type string. The action creator accepts a single argument, which will be included in the action object as a field called payload. The action creator function will also have its toString() overriden so that it returns the action type, allowing it to be used in reducer logic that is looking for that action type.

    Parameter type

    The action type to use for created actions.

    Parameter prepare

    (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }. If this is given, the resulting action creator will pass its arguments to this method to calculate payload & meta.

    Modifiers

    • @public

function createAsyncThunk

createAsyncThunk: {
<Returned, ThunkArg = void>(
typePrefix: string,
payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, {}>,
options?: AsyncThunkOptions<ThunkArg, {}>
): AsyncThunk<Returned, ThunkArg, {}>;
<Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig>(
typePrefix: string,
payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, ThunkApiConfig>,
options?: AsyncThunkOptions<ThunkArg, ThunkApiConfig>
): AsyncThunk<Returned, ThunkArg, ThunkApiConfig>;
};
  • Parameter typePrefix

    Parameter payloadCreator

    Parameter options

    Modifiers

    • @public

function createEntityAdapter

createEntityAdapter: <T>(options?: {
selectId?: IdSelector<T>;
sortComparer?: false | Comparer<T>;
}) => EntityAdapter<T>;
  • Parameter options

    Modifiers

    • @public

function createImmutableStateInvariantMiddleware

createImmutableStateInvariantMiddleware: (
options?: ImmutableStateInvariantMiddlewareOptions
) => Middleware;
  • Creates a middleware that checks whether any state was mutated in between dispatches or during a dispatch. If any mutations are detected, an error is thrown.

    Parameter options

    Middleware options.

    Modifiers

    • @public

function createListenerMiddleware

createListenerMiddleware: <
S = unknown,
D extends Dispatch<AnyAction> = ThunkDispatch<S, unknown, AnyAction>,
ExtraArgument = unknown
>(
middlewareOptions?: CreateListenerMiddlewareOptions<ExtraArgument>
) => ListenerMiddlewareInstance<S, D, ExtraArgument>;
  • Modifiers

    • @public

function createReducer

createReducer: {
<S extends unknown>(
initialState: S | (() => S),
builderCallback: (builder: ActionReducerMapBuilder<S>) => void
): ReducerWithInitialState<S>;
<S extends unknown, CR extends CaseReducers<S, any> = CaseReducers<S, any>>(
initialState: S | (() => S),
actionsMap: CR,
actionMatchers?: ActionMatcherDescriptionCollection<S>,
defaultCaseReducer?: CaseReducer<S, AnyAction>
): any;
};
  • A utility function that allows defining a reducer as a mapping from action type to *case reducer* functions that handle these action types. The reducer's initial state is passed as the first argument.

    Parameter initialState

    State | (() => State): The initial state that should be used when the reducer is called the first time. This may also be a "lazy initializer" function, which should return an initial state value when called. This will be used whenever the reducer is called with undefined as its state value, and is primarily useful for cases like reading initial state from localStorage.

    Parameter builderCallback

    (builder: Builder) => void A callback that receives a *builder* object to define case reducers via calls to builder.addCase(actionCreatorOrType, reducer).

    Remarks

    The body of every case reducer is implicitly wrapped with a call to produce() from the [immer](https://github.com/mweststrate/immer) library. This means that rather than returning a new state object, you can also mutate the passed-in state object directly; these mutations will then be automatically and efficiently translated into copies, giving you both convenience and immutability.

    This overload accepts a callback function that receives a builder object as its argument. That builder provides addCase, addMatcher and addDefaultCase functions that may be called to define what actions this reducer will handle.

    Example 1

    import {
    createAction,
    createReducer,
    AnyAction,
    PayloadAction,
    } from "@reduxjs/toolkit";
    const increment = createAction<number>("increment");
    const decrement = createAction<number>("decrement");
    function isActionWithNumberPayload(
    action: AnyAction
    ): action is PayloadAction<number> {
    return typeof action.payload === "number";
    }
    const reducer = createReducer(
    {
    counter: 0,
    sumOfNumberPayloads: 0,
    unhandledActions: 0,
    },
    (builder) => {
    builder
    .addCase(increment, (state, action) => {
    // action is inferred correctly here
    state.counter += action.payload;
    })
    // You can chain calls, or have separate `builder.addCase()` lines each time
    .addCase(decrement, (state, action) => {
    state.counter -= action.payload;
    })
    // You can apply a "matcher function" to incoming actions
    .addMatcher(isActionWithNumberPayload, (state, action) => {})
    // and provide a default case if no other handlers matched
    .addDefaultCase((state, action) => {});
    }
    );

    Modifiers

    • @public
  • A utility function that allows defining a reducer as a mapping from action type to *case reducer* functions that handle these action types. The reducer's initial state is passed as the first argument.

    The body of every case reducer is implicitly wrapped with a call to produce() from the [immer](https://github.com/mweststrate/immer) library. This means that rather than returning a new state object, you can also mutate the passed-in state object directly; these mutations will then be automatically and efficiently translated into copies, giving you both convenience and immutability.

    This overload accepts an object where the keys are string action types, and the values are case reducer functions to handle those action types.

    Parameter initialState

    State | (() => State): The initial state that should be used when the reducer is called the first time. This may also be a "lazy initializer" function, which should return an initial state value when called. This will be used whenever the reducer is called with undefined as its state value, and is primarily useful for cases like reading initial state from localStorage.

    Parameter actionsMap

    An object mapping from action types to _case reducers_, each of which handles one specific action type.

    Parameter actionMatchers

    An array of matcher definitions in the form {matcher, reducer}. All matching reducers will be executed in order, independently if a case reducer matched or not.

    Parameter defaultCaseReducer

    A "default case" reducer that is executed if no case reducer and no matcher reducer was executed for this action.

    Example 1

    const counterReducer = createReducer(0, {
    increment: (state, action) => state + action.payload,
    decrement: (state, action) => state - action.payload
    })
    // Alternately, use a "lazy initializer" to provide the initial state
    // (works with either form of createReducer)
    const initialState = () => 0
    const counterReducer = createReducer(initialState, {
    increment: (state, action) => state + action.payload,
    decrement: (state, action) => state - action.payload
    })

    Action creators that were generated using [createAction](./createAction) may be used directly as the keys here, using computed property syntax:

    const increment = createAction('increment')
    const decrement = createAction('decrement')
    const counterReducer = createReducer(0, {
    [increment]: (state, action) => state + action.payload,
    [decrement.type]: (state, action) => state - action.payload
    })

    Modifiers

    • @public

function createSerializableStateInvariantMiddleware

createSerializableStateInvariantMiddleware: (
options?: SerializableStateInvariantMiddlewareOptions
) => Middleware;
  • Creates a middleware that, after every state change, checks if the new state is serializable. If a non-serializable value is found within the state, an error is printed to the console.

    Parameter options

    Middleware options.

    Modifiers

    • @public

function createSlice

createSlice: <
State,
CaseReducers extends SliceCaseReducers<State>,
Name extends string = string
>(
options: CreateSliceOptions<State, CaseReducers, Name>
) => Slice<State, CaseReducers, Name>;
  • A function that accepts an initial state, an object full of reducer functions, and a "slice name", and automatically generates action creators and action types that correspond to the reducers and state.

    The reducer argument is passed to createReducer().

    Modifiers

    • @public

function findNonSerializableValue

findNonSerializableValue: (
value: unknown,
path?: string,
isSerializable?: (value: unknown) => boolean,
getEntries?: (value: unknown) => [string, any][],
ignoredPaths?: readonly string[]
) => NonSerializableValue | false;
  • Modifiers

    • @public

function getDefaultMiddleware

getDefaultMiddleware: <
S = any,
O extends Partial<GetDefaultMiddlewareOptions> = {
thunk: true;
immutableCheck: true;
serializableCheck: true;
}
>(
options?: O
) => MiddlewareArray<ExcludeFromTuple<[ThunkMiddlewareFor<S, O>], never>>;
  • Returns any array containing the default middleware installed by configureStore(). Useful if you want to configure your store with a custom middleware array but still keep the default set.

    The default middleware used by configureStore().

    Modifiers

    • @public

    Deprecated

    Prefer to use the callback notation for the middleware option in configureStore to access a pre-typed getDefaultMiddleware instead.

function getType

getType: <T extends string>(actionCreator: PayloadActionCreator<any, T>) => T;
  • Returns the action type of the actions created by the passed createAction()-generated action creator (arbitrary action creators are not supported).

    Parameter action

    The action creator whose action type to get.

    Returns

    The action type used by the action creator.

    Modifiers

    • @public

function isAllOf

isAllOf: <Matchers extends [Matcher<any>, ...Matcher<any>[]]>(
...matchers: Matchers
) => (
action: any
) => action is UnionToIntersection<ActionFromMatcher<Matchers[number]>>;
  • A higher-order function that returns a function that may be used to check whether an action matches all of the supplied type guards or action creators.

    Parameter matchers

    The type guards or action creators to match against.

    Modifiers

    • @public

function isAnyOf

isAnyOf: <Matchers extends [Matcher<any>, ...Matcher<any>[]]>(
...matchers: Matchers
) => (action: any) => action is ActionFromMatcher<Matchers[number]>;
  • A higher-order function that returns a function that may be used to check whether an action matches any one of the supplied type guards or action creators.

    Parameter matchers

    The type guards or action creators to match against.

    Modifiers

    • @public

function isAsyncThunkAction

isAsyncThunkAction: {
(): (action: any) => action is UnknownAsyncThunkAction;
<AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]>(
...asyncThunks: AsyncThunks
): (action: any) => action is ActionsFromAsyncThunk<AsyncThunks[number]>;
(action: any): action is UnknownAsyncThunkAction;
};
  • A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator.

    Modifiers

    • @public
  • A higher-order function that returns a function that may be used to check whether an action belongs to one of the provided async thunk action creators.

    Parameter asyncThunks

    (optional) The async thunk action creators to match against.

    Modifiers

    • @public
  • Tests if action is a thunk action

    Modifiers

    • @public

function isFulfilled

isFulfilled: {
(): (
action: any
) => action is PayloadAction<
unknown,
string,
{ arg: unknown; requestId: string; requestStatus: 'fulfilled' },
never
>;
<AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]>(
...asyncThunks: AsyncThunks
): (
action: any
) => action is ActionFromMatcher<AsyncThunks[number]['fulfilled']>;
(action: any): action is PayloadAction<
unknown,
string,
{ arg: unknown; requestId: string; requestStatus: 'fulfilled' },
never
>;
};
  • A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator, and that the action is fulfilled.

    Modifiers

    • @public
  • A higher-order function that returns a function that may be used to check whether an action belongs to one of the provided async thunk action creators, and that the action is fulfilled.

    Parameter asyncThunks

    (optional) The async thunk action creators to match against.

    Modifiers

    • @public
  • Tests if action is a fulfilled thunk action

    Modifiers

    • @public

function isImmutableDefault

isImmutableDefault: (value: unknown) => boolean;
  • The default isImmutable function.

    Modifiers

    • @public

function isPending

isPending: {
(): (
action: any
) => action is PayloadAction<
undefined,
string,
{ arg: unknown; requestId: string; requestStatus: 'pending' },
never
>;
<AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]>(
...asyncThunks: AsyncThunks
): (action: any) => action is ActionFromMatcher<AsyncThunks[number]['pending']>;
(action: any): action is PayloadAction<
undefined,
string,
{ arg: unknown; requestId: string; requestStatus: 'pending' },
never
>;
};
  • A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator, and that the action is pending.

    Modifiers

    • @public
  • A higher-order function that returns a function that may be used to check whether an action belongs to one of the provided async thunk action creators, and that the action is pending.

    Parameter asyncThunks

    (optional) The async thunk action creators to match against.

    Modifiers

    • @public
  • Tests if action is a pending thunk action

    Modifiers

    • @public

function isPlain

isPlain: (val: any) => boolean;
  • Returns true if the passed value is "plain", i.e. a value that is either directly JSON-serializable (boolean, number, string, array, plain object) or undefined.

    Parameter val

    The value to check.

    Modifiers

    • @public

function isPlainObject

isPlainObject: (value: unknown) => value is object;
  • Returns true if the passed value is "plain" object, i.e. an object whose prototype is the root Object.prototype. This includes objects created using object literals, but not for instance for class instances.

    Parameter value

    The value to inspect.

    Returns

    {boolean} True if the argument appears to be a plain object.

    Modifiers

    • @public

function isRejected

isRejected: {
(): (
action: any
) => action is PayloadAction<
unknown,
string,
{
arg: unknown;
requestId: string;
requestStatus: 'rejected';
aborted: boolean;
condition: boolean;
} & ({ rejectedWithValue: true } | ({ rejectedWithValue: false } & {})),
SerializedError
>;
<AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]>(
...asyncThunks: AsyncThunks
): (action: any) => action is ActionFromMatcher<AsyncThunks[number]['rejected']>;
(action: any): action is PayloadAction<
unknown,
string,
{
arg: unknown;
requestId: string;
requestStatus: 'rejected';
aborted: boolean;
condition: boolean;
} & ({ rejectedWithValue: true } | ({ rejectedWithValue: false } & {})),
SerializedError
>;
};
  • A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator, and that the action is rejected.

    Modifiers

    • @public
  • A higher-order function that returns a function that may be used to check whether an action belongs to one of the provided async thunk action creators, and that the action is rejected.

    Parameter asyncThunks

    (optional) The async thunk action creators to match against.

    Modifiers

    • @public
  • Tests if action is a rejected thunk action

    Modifiers

    • @public

function isRejectedWithValue

isRejectedWithValue: {
(): (
action: any
) => action is PayloadAction<
unknown,
string,
{
arg: unknown;
requestId: string;
requestStatus: 'rejected';
aborted: boolean;
condition: boolean;
} & ({ rejectedWithValue: true } | ({ rejectedWithValue: false } & {})),
SerializedError
>;
<AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk[]]>(
...asyncThunks: AsyncThunks
): (
action: any
) => action is RejectedWithValueActionFromAsyncThunk<AsyncThunks[number]>;
(action: any): action is PayloadAction<
unknown,
string,
{
arg: unknown;
requestId: string;
requestStatus: 'rejected';
aborted: boolean;
condition: boolean;
} & ({ rejectedWithValue: true } | ({ rejectedWithValue: false } & {})),
SerializedError
>;
};
  • A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator, and that the action is rejected with value.

    Modifiers

    • @public
  • A higher-order function that returns a function that may be used to check whether an action belongs to one of the provided async thunk action creators, and that the action is rejected with value.

    Parameter asyncThunks

    (optional) The async thunk action creators to match against.

    Modifiers

    • @public
  • Tests if action is a rejected thunk action with value

    Modifiers

    • @public

function miniSerializeError

miniSerializeError: (value: any) => SerializedError;
  • Serializes an error into a plain object. Reworked from https://github.com/sindresorhus/serialize-error

    Modifiers

    • @public

function nanoid

nanoid: (size?: number) => string;
  • Modifiers

    • @public

function unwrapResult

unwrapResult: <R extends UnwrappableAction>(
action: R
) => UnwrappedActionPayload<R>;
  • Modifiers

    • @public

Classes

class MiddlewareArray

class MiddlewareArray<Middlewares extends Middleware<any, any>[]> extends Array<
Middlewares[number]
> {}
  • Modifiers

    • @public

constructor

constructor(...items: Middleware<any, any>[]);

    property [Symbol.species]

    static readonly [Symbol.species]: any;

      method concat

      concat: {
      <AdditionalMiddlewares extends readonly Middleware<any, any>[]>(
      items: AdditionalMiddlewares
      ): MiddlewareArray<[...Middlewares, ...AdditionalMiddlewares]>;
      <AdditionalMiddlewares extends readonly Middleware<any, any>[]>(
      ...items: AdditionalMiddlewares
      ): MiddlewareArray<[...Middlewares, ...AdditionalMiddlewares]>;
      };

        method prepend

        prepend: {
        <AdditionalMiddlewares extends readonly Middleware<any, any>[]>(
        items: AdditionalMiddlewares
        ): MiddlewareArray<[...AdditionalMiddlewares, ...Middlewares]>;
        <AdditionalMiddlewares extends readonly Middleware<any, any>[]>(
        ...items: AdditionalMiddlewares
        ): MiddlewareArray<[...AdditionalMiddlewares, ...Middlewares]>;
        };

          class TaskAbortError

          class TaskAbortError implements SerializedError {}

            constructor

            constructor(code: string);

              property code

              code: string;

                property message

                message: string;

                  property name

                  name: string;

                    Interfaces

                    interface ActionCreatorWithNonInferrablePayload

                    interface ActionCreatorWithNonInferrablePayload<T extends string = string>
                    extends BaseActionCreator<unknown, T> {}
                    • An action creator of type T whose payload type could not be inferred. Accepts everything as payload.

                      {redux#ActionCreator}

                      Modifiers

                      • @public

                    call signature

                    <PT extends unknown>(payload: PT): PayloadAction<PT, T>;

                    interface ActionCreatorWithOptionalPayload

                    interface ActionCreatorWithOptionalPayload<P, T extends string = string>
                    extends BaseActionCreator<P, T> {}
                    • An action creator of type T that takes an optional payload of type P.

                      {redux#ActionCreator}

                      Modifiers

                      • @public

                    call signature

                    (payload?: P): PayloadAction<P, T>;
                    • Calling this redux#ActionCreator with an argument will return a PayloadAction of type T with a payload of P. Calling it without an argument will return a PayloadAction with a payload of undefined.

                    interface ActionCreatorWithoutPayload

                    interface ActionCreatorWithoutPayload<T extends string = string>
                    extends BaseActionCreator<undefined, T> {}
                    • An action creator of type T that takes no payload.

                      {redux#ActionCreator}

                      Modifiers

                      • @public

                    call signature

                    (): PayloadAction<undefined, T>;

                    interface ActionCreatorWithPayload

                    interface ActionCreatorWithPayload<P, T extends string = string>
                    extends BaseActionCreator<P, T> {}
                    • An action creator of type T that requires a payload of type P.

                      {redux#ActionCreator}

                      Modifiers

                      • @public

                    call signature

                    (payload: P): PayloadAction<P, T>;

                    interface ActionCreatorWithPreparedPayload

                    interface ActionCreatorWithPreparedPayload<
                    Args extends unknown[],
                    P,
                    T extends string = string,
                    E = never,
                    M = never
                    > extends BaseActionCreator<P, T, M, E> {}
                    • An action creator that takes multiple arguments that are passed to a PrepareAction method to create the final Action.

                      Modifiers

                      • @public

                    call signature

                    (...args: Args): PayloadAction<P, T, M, E>;
                    • Calling this redux#ActionCreator with Args will return an Action with a payload of type P and (depending on the PrepareAction method used) a meta- and error property of types M and E respectively.

                    interface ActionReducerMapBuilder

                    interface ActionReducerMapBuilder<State> {}
                    • A builder for an action <-> reducer map.

                      Modifiers

                      • @public

                    method addCase

                    addCase: {
                    <ActionCreator extends TypedActionCreator<string>>(
                    actionCreator: ActionCreator,
                    reducer: CaseReducer<State, ReturnType<ActionCreator>>
                    ): ActionReducerMapBuilder<State>;
                    <Type extends string, A extends Action<Type>>(
                    type: Type,
                    reducer: CaseReducer<State, A>
                    ): ActionReducerMapBuilder<State>;
                    };
                    • Adds a case reducer to handle a single exact action type.

                      Parameter actionCreator

                      Either a plain action type string, or an action creator generated by [createAction](./createAction) that can be used to determine the action type.

                      Parameter reducer

                      The actual case reducer function.

                      Remarks

                      All calls to builder.addCase must come before any calls to builder.addMatcher or builder.addDefaultCase.

                    method addDefaultCase

                    addDefaultCase: (reducer: CaseReducer<State, AnyAction>) => {};
                    • Adds a "default case" reducer that is executed if no case reducer and no matcher reducer was executed for this action.

                      Parameter reducer

                      The fallback "default case" reducer function.

                      Example 1

                      ```ts import { createReducer } from '@reduxjs/toolkit' const initialState = { otherActions: 0 } const reducer = createReducer(initialState, builder => { builder // .addCase(...) // .addMatcher(...) .addDefaultCase((state, action) => { state.otherActions++ }) }) ```

                    method addMatcher

                    addMatcher: <A>(
                    matcher: TypeGuard<A> | ((action: any) => boolean),
                    reducer: CaseReducer<State, A extends AnyAction ? A : A & AnyAction>
                    ) => Omit<ActionReducerMapBuilder<State>, 'addCase'>;
                    • Allows you to match your incoming actions against your own filter function instead of only the action.type property.

                      Parameter matcher

                      A matcher function. In TypeScript, this should be a [type predicate](https://www.typescriptlang.org/docs/handbook/advanced-types.html#using-type-predicates) function

                      Parameter reducer

                      The actual case reducer function.

                      Remarks

                      If multiple matcher reducers match, all of them will be executed in the order they were defined in - even if a case reducer already matched. All calls to builder.addMatcher must come after any calls to builder.addCase and before any calls to builder.addDefaultCase.

                      Example 1

                      ```ts import { createAction, createReducer, AsyncThunk, AnyAction, } from "@reduxjs/toolkit";

                      type GenericAsyncThunk = AsyncThunk<unknown, unknown, any>;

                      type PendingAction = ReturnType<GenericAsyncThunk["pending"]>; type RejectedAction = ReturnType<GenericAsyncThunk["rejected"]>; type FulfilledAction = ReturnType<GenericAsyncThunk["fulfilled"]>;

                      const initialState: Record<string, string> = {}; const resetAction = createAction("reset-tracked-loading-state");

                      function isPendingAction(action: AnyAction): action is PendingAction { return action.type.endsWith("/pending"); }

                      const reducer = createReducer(initialState, (builder) => { builder .addCase(resetAction, () => initialState) // matcher can be defined outside as a type predicate function .addMatcher(isPendingAction, (state, action) => { state[action.meta.requestId] = "pending"; }) .addMatcher( // matcher can be defined inline as a type predicate function (action): action is RejectedAction => action.type.endsWith("/rejected"), (state, action) => { state[action.meta.requestId] = "rejected"; } ) // matcher can just return boolean and the matcher can receive a generic argument .addMatcher( (action) => action.type.endsWith("/fulfilled"), (state, action) => { state[action.meta.requestId] = "fulfilled"; } ); }); ```

                    interface AsyncTaskExecutor

                    interface AsyncTaskExecutor<T> {}
                    • Modifiers

                      • @public

                    call signature

                    (forkApi: ForkedTaskAPI): Promise<T>;

                      interface ConfigureStoreOptions

                      interface ConfigureStoreOptions<
                      S = any,
                      A extends Action = AnyAction,
                      M extends Middlewares<S> = Middlewares<S>
                      > {}
                      • Options for configureStore().

                        Modifiers

                        • @public

                      property devTools

                      devTools?: boolean | DevToolsOptions;
                      • Whether to enable Redux DevTools integration. Defaults to true.

                        Additional configuration can be done by passing Redux DevTools options

                      property enhancers

                      enhancers?: StoreEnhancer[] | ConfigureEnhancersCallback;
                      • The store enhancers to apply. See Redux's createStore(). All enhancers will be included before the DevTools Extension enhancer. If you need to customize the order of enhancers, supply a callback function that will receive the original array (ie, [applyMiddleware]), and should return a new array (such as [applyMiddleware, offline]). If you only need to add middleware, you can use the middleware parameter instead.

                      property middleware

                      middleware?: ((getDefaultMiddleware: CurriedGetDefaultMiddleware<S>) => M) | M;
                      • An array of Redux middleware to install. If not supplied, defaults to the set of middleware returned by getDefaultMiddleware().

                        Example 1

                        middleware: (gDM) => gDM().concat(logger, apiMiddleware, yourCustomMiddleware)

                        See Also

                        • https://redux-toolkit.js.org/api/getDefaultMiddleware#intended-usage

                      property preloadedState

                      preloadedState?: PreloadedState<CombinedState<NoInfer<S>>>;
                      • The initial state, same as Redux's createStore. You may optionally specify it to hydrate the state from the server in universal apps, or to restore a previously serialized user session. If you use combineReducers() to produce the root reducer function (either directly or indirectly by passing an object as reducer), this must be an object with the same shape as the reducer map keys.

                      property reducer

                      reducer: Reducer<S, A> | ReducersMapObject<S, A>;
                      • A single reducer function that will be used as the root reducer, or an object of slice reducers that will be passed to combineReducers().

                      interface CreateListenerMiddlewareOptions

                      interface CreateListenerMiddlewareOptions<ExtraArgument = unknown> {}
                      • Modifiers

                        • @public

                      property extra

                      extra?: ExtraArgument;

                        property onError

                        onError?: ListenerErrorHandler;
                        • Receives synchronous errors that are raised by listener and listenerOption.predicate.

                        interface CreateSliceOptions

                        interface CreateSliceOptions<
                        State = any,
                        CR extends SliceCaseReducers<State> = SliceCaseReducers<State>,
                        Name extends string = string
                        > {}
                        • Options for createSlice().

                          Modifiers

                          • @public

                        property extraReducers

                        extraReducers?:
                        | CaseReducers<NoInfer<State>, any>
                        | ((builder: ActionReducerMapBuilder<NoInfer<State>>) => void);
                        • A callback that receives a *builder* object to define case reducers via calls to builder.addCase(actionCreatorOrType, reducer).

                          Alternatively, a mapping from action types to action-type-specific *case reducer* functions. These reducers should have existing action types used as the keys, and action creators will _not_ be generated.

                          Example 1

                          ```ts import { createAction, createSlice, Action, AnyAction } from '@reduxjs/toolkit' const incrementBy = createAction('incrementBy') const decrement = createAction('decrement')

                          interface RejectedAction extends Action { error: Error }

                          function isRejectedAction(action: AnyAction): action is RejectedAction { return action.type.endsWith('rejected') }

                          createSlice({ name: 'counter', initialState: 0, reducers: {}, extraReducers: builder => { builder .addCase(incrementBy, (state, action) => { // action is inferred correctly here if using TS }) // You can chain calls, or have separate builder.addCase() lines each time .addCase(decrement, (state, action) => {}) // You can match a range of action types .addMatcher( isRejectedAction, // action will be inferred as a RejectedAction due to isRejectedAction being defined as a type guard (state, action) => {} ) // and provide a default case if no other handlers matched .addDefaultCase((state, action) => {}) } }) ```

                        property initialState

                        initialState: State | (() => State);
                        • The initial state that should be used when the reducer is called the first time. This may also be a "lazy initializer" function, which should return an initial state value when called. This will be used whenever the reducer is called with undefined as its state value, and is primarily useful for cases like reading initial state from localStorage.

                        property name

                        name: Name;
                        • The slice's name. Used to namespace the generated action types.

                        property reducers

                        reducers: ValidateSliceCaseReducers<State, CR>;
                        • A mapping from action types to action-type-specific *case reducer* functions. For every action type, a matching action creator will be generated using createAction().

                        interface Dictionary

                        interface Dictionary<T> extends DictionaryNum<T> {}
                        • Modifiers

                          • @public

                        index signature

                        [id: string]: T | undefined;

                          interface EnhancedStore

                          interface EnhancedStore<
                          S = any,
                          A extends Action = AnyAction,
                          M extends Middlewares<S> = Middlewares<S>
                          > extends Store<S, A> {}
                          • A Redux store returned by configureStore(). Supports dispatching side-effectful _thunks_ in addition to plain actions.

                            Modifiers

                            • @public

                          property dispatch

                          dispatch: ExtractDispatchExtensions<M> & Dispatch<A>;
                          • The dispatch method of your store, enhanced by all its middlewares.

                          interface EntityAdapter

                          interface EntityAdapter<T> extends EntityStateAdapter<T> {}
                          • Modifiers

                            • @public

                          property selectId

                          selectId: IdSelector<T>;

                            property sortComparer

                            sortComparer: false | Comparer<T>;

                              method getInitialState

                              getInitialState: {
                              (): EntityState<T>;
                              <S extends object>(state: S): EntityState<T> & S;
                              };

                                method getSelectors

                                getSelectors: {
                                (): EntitySelectors<T, EntityState<T>>;
                                <V>(selectState: (state: V) => EntityState<T>): EntitySelectors<T, V>;
                                };

                                  interface EntitySelectors

                                  interface EntitySelectors<T, V> {}
                                  • Modifiers

                                    • @public

                                  property selectAll

                                  selectAll: (state: V) => T[];

                                    property selectById

                                    selectById: (state: V, id: EntityId) => T | undefined;

                                      property selectEntities

                                      selectEntities: (state: V) => Dictionary<T>;

                                        property selectIds

                                        selectIds: (state: V) => EntityId[];

                                          property selectTotal

                                          selectTotal: (state: V) => number;

                                            interface EntityState

                                            interface EntityState<T> {}
                                            • Modifiers

                                              • @public

                                            property entities

                                            entities: Dictionary<T>;

                                              property ids

                                              ids: EntityId[];

                                                interface EntityStateAdapter

                                                interface EntityStateAdapter<T> {}
                                                • Modifiers

                                                  • @public

                                                method addMany

                                                addMany: {
                                                <S extends EntityState<T>>(
                                                state: PreventAny<S, T>,
                                                entities: readonly T[] | Record<EntityId, T>
                                                ): S;
                                                <S extends EntityState<T>>(
                                                state: IsAny<S, EntityState<T>, S>,
                                                entities: { payload: readonly T[] | Record<EntityId, T>; type: string }
                                                ): S;
                                                };

                                                  method addOne

                                                  addOne: {
                                                  <S extends EntityState<T>>(state: PreventAny<S, T>, entity: T): S;
                                                  <S extends EntityState<T>>(
                                                  state: IsAny<S, EntityState<T>, S>,
                                                  action: { payload: T; type: string }
                                                  ): S;
                                                  };

                                                    method removeAll

                                                    removeAll: <S extends EntityState<T>>(state: PreventAny<S, T>) => S;

                                                      method removeMany

                                                      removeMany: {
                                                      <S extends EntityState<T>>(
                                                      state: PreventAny<S, T>,
                                                      keys: readonly EntityId[]
                                                      ): S;
                                                      <S extends EntityState<T>>(
                                                      state: IsAny<S, EntityState<T>, S>,
                                                      keys: { payload: readonly EntityId[]; type: string }
                                                      ): S;
                                                      };

                                                        method removeOne

                                                        removeOne: {
                                                        <S extends EntityState<T>>(state: PreventAny<S, T>, key: EntityId): S;
                                                        <S extends EntityState<T>>(
                                                        state: IsAny<S, EntityState<T>, S>,
                                                        key: { payload: EntityId; type: string }
                                                        ): S;
                                                        };

                                                          method setAll

                                                          setAll: {
                                                          <S extends EntityState<T>>(
                                                          state: PreventAny<S, T>,
                                                          entities: readonly T[] | Record<EntityId, T>
                                                          ): S;
                                                          <S extends EntityState<T>>(
                                                          state: IsAny<S, EntityState<T>, S>,
                                                          entities: { payload: readonly T[] | Record<EntityId, T>; type: string }
                                                          ): S;
                                                          };

                                                            method setMany

                                                            setMany: {
                                                            <S extends EntityState<T>>(
                                                            state: PreventAny<S, T>,
                                                            entities: readonly T[] | Record<EntityId, T>
                                                            ): S;
                                                            <S extends EntityState<T>>(
                                                            state: IsAny<S, EntityState<T>, S>,
                                                            entities: { payload: readonly T[] | Record<EntityId, T>; type: string }
                                                            ): S;
                                                            };

                                                              method setOne

                                                              setOne: {
                                                              <S extends EntityState<T>>(state: PreventAny<S, T>, entity: T): S;
                                                              <S extends EntityState<T>>(
                                                              state: IsAny<S, EntityState<T>, S>,
                                                              action: { payload: T; type: string }
                                                              ): S;
                                                              };

                                                                method updateMany

                                                                updateMany: {
                                                                <S extends EntityState<T>>(
                                                                state: PreventAny<S, T>,
                                                                updates: ReadonlyArray<Update<T>>
                                                                ): S;
                                                                <S extends EntityState<T>>(
                                                                state: IsAny<S, EntityState<T>, S>,
                                                                updates: { payload: readonly Update<T>[]; type: string }
                                                                ): S;
                                                                };

                                                                  method updateOne

                                                                  updateOne: {
                                                                  <S extends EntityState<T>>(state: PreventAny<S, T>, update: Update<T>): S;
                                                                  <S extends EntityState<T>>(
                                                                  state: IsAny<S, EntityState<T>, S>,
                                                                  update: { payload: Update<T>; type: string }
                                                                  ): S;
                                                                  };

                                                                    method upsertMany

                                                                    upsertMany: {
                                                                    <S extends EntityState<T>>(
                                                                    state: PreventAny<S, T>,
                                                                    entities: readonly T[] | Record<EntityId, T>
                                                                    ): S;
                                                                    <S extends EntityState<T>>(
                                                                    state: IsAny<S, EntityState<T>, S>,
                                                                    entities: { payload: readonly T[] | Record<EntityId, T>; type: string }
                                                                    ): S;
                                                                    };

                                                                      method upsertOne

                                                                      upsertOne: {
                                                                      <S extends EntityState<T>>(state: PreventAny<S, T>, entity: T): S;
                                                                      <S extends EntityState<T>>(
                                                                      state: IsAny<S, EntityState<T>, S>,
                                                                      entity: { payload: T; type: string }
                                                                      ): S;
                                                                      };

                                                                        interface ForkedTask

                                                                        interface ForkedTask<T> {}
                                                                        • Modifiers

                                                                          • @public

                                                                        property result

                                                                        result: Promise<TaskResult<T>>;
                                                                        • A promise that resolves when the task is either completed or cancelled or rejects if parent listener execution is cancelled or completed.

                                                                          ### Example

                                                                          const result = await fork(async (forkApi) => Promise.resolve(4)).result
                                                                          if(result.status === 'ok') {
                                                                          console.log(result.value) // logs 4
                                                                          }}

                                                                        method cancel

                                                                        cancel: () => void;
                                                                        • Cancel task if it is in progress or not yet started, it is noop otherwise.

                                                                        interface ForkedTaskAPI

                                                                        interface ForkedTaskAPI {}
                                                                        • Modifiers

                                                                          • @public

                                                                        property signal

                                                                        signal: AbortSignal;
                                                                        • An abort signal whose aborted property is set to true if the task execution is either aborted or completed.

                                                                          See Also

                                                                          • https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal

                                                                        method delay

                                                                        delay: (timeoutMs: number) => Promise<void>;
                                                                        • Returns a promise that resolves after timeoutMs or rejects if the task or the parent listener has been cancelled or is completed.

                                                                          Parameter timeoutMs

                                                                        method pause

                                                                        pause: <W>(waitFor: Promise<W>) => Promise<W>;
                                                                        • Returns a promise that resolves when waitFor resolves or rejects if the task or the parent listener has been cancelled or is completed.

                                                                        interface ImmutableStateInvariantMiddlewareOptions

                                                                        interface ImmutableStateInvariantMiddlewareOptions {}
                                                                        • Options for createImmutableStateInvariantMiddleware().

                                                                          Modifiers

                                                                          • @public

                                                                        property ignore

                                                                        ignore?: string[];

                                                                          property ignoredPaths

                                                                          ignoredPaths?: string[];
                                                                          • An array of dot-separated path strings that match named nodes from the root state to ignore when checking for immutability. Defaults to undefined

                                                                          property isImmutable

                                                                          isImmutable?: IsImmutableFunc;
                                                                          • Callback function to check if a value is considered to be immutable. This function is applied recursively to every value contained in the state. The default implementation will return true for primitive types (like numbers, strings, booleans, null and undefined).

                                                                          property warnAfter

                                                                          warnAfter?: number;
                                                                          • Print a warning if checks take longer than N ms. Default: 32ms

                                                                          interface ListenerEffectAPI

                                                                          interface ListenerEffectAPI<
                                                                          State,
                                                                          Dispatch extends ReduxDispatch<AnyAction>,
                                                                          ExtraArgument = unknown
                                                                          > extends MiddlewareAPI<Dispatch, State> {}
                                                                          • Modifiers

                                                                            • @public

                                                                          property cancelActiveListeners

                                                                          cancelActiveListeners: () => void;
                                                                          • Cancels all other running instances of this same listener except for the one that made this call.

                                                                          property condition

                                                                          condition: ConditionFunction<State>;
                                                                          • Returns a promise that resolves when the input predicate returns true or rejects if the listener has been cancelled or is completed.

                                                                            The return value is true if the predicate succeeds or false if a timeout is provided and expires first.

                                                                            ### Example

                                                                            const updateBy = createAction<number>('counter/updateBy');
                                                                            middleware.startListening({
                                                                            actionCreator: updateBy,
                                                                            async effect(_, { condition }) {
                                                                            // wait at most 3s for `updateBy` actions.
                                                                            if(await condition(updateBy.match, 3_000)) {
                                                                            // `updateBy` has been dispatched twice in less than 3s.
                                                                            }
                                                                            }
                                                                            })

                                                                          property extra

                                                                          extra: ExtraArgument;

                                                                            property getOriginalState

                                                                            getOriginalState: () => State;
                                                                            • Returns the store state as it existed when the action was originally dispatched, _before_ the reducers ran.

                                                                              ### Synchronous invocation

                                                                              This function can **only** be invoked **synchronously**, it throws error otherwise.

                                                                              Example 1

                                                                              middleware.startListening({
                                                                              predicate: () => true,
                                                                              async effect(_, { getOriginalState }) {
                                                                              getOriginalState(); // sync: OK!
                                                                              setTimeout(getOriginalState, 0); // async: throws Error
                                                                              await Promise().resolve();
                                                                              getOriginalState() // async: throws Error
                                                                              }
                                                                              })

                                                                            property signal

                                                                            signal: AbortSignal;
                                                                            • An abort signal whose aborted property is set to true if the listener execution is either aborted or completed.

                                                                              See Also

                                                                              • https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal

                                                                            property take

                                                                            take: TakePattern<State>;
                                                                            • Returns a promise that resolves when the input predicate returns true or rejects if the listener has been cancelled or is completed.

                                                                              The return value is the [action, currentState, previousState] combination that the predicate saw as arguments.

                                                                              The promise resolves to null if a timeout is provided and expires first,

                                                                              ### Example

                                                                              const updateBy = createAction<number>('counter/updateBy');
                                                                              middleware.startListening({
                                                                              actionCreator: updateBy,
                                                                              async effect(_, { take }) {
                                                                              const [{ payload }] = await take(updateBy.match);
                                                                              console.log(payload); // logs 5;
                                                                              }
                                                                              })
                                                                              store.dispatch(updateBy(5));

                                                                            method delay

                                                                            delay: (timeoutMs: number) => Promise<void>;
                                                                            • Returns a promise that resolves after timeoutMs or rejects if the listener has been cancelled or is completed.

                                                                            method fork

                                                                            fork: <T>(executor: ForkedTaskExecutor<T>) => ForkedTask<T>;
                                                                            • Queues in the next microtask the execution of a task.

                                                                              Parameter executor

                                                                            method pause

                                                                            pause: <M>(promise: Promise<M>) => Promise<M>;
                                                                            • Returns a promise that resolves when waitFor resolves or rejects if the listener has been cancelled or is completed.

                                                                              Parameter promise

                                                                            method subscribe

                                                                            subscribe: () => void;
                                                                            • It will subscribe a listener if it was previously removed, noop otherwise.

                                                                            method unsubscribe

                                                                            unsubscribe: () => void;
                                                                            • Removes the listener entry from the middleware and prevent future instances of the listener from running.

                                                                              It does **not** cancel any active instances.

                                                                            interface ListenerErrorHandler

                                                                            interface ListenerErrorHandler {}
                                                                            • Gets notified with synchronous and asynchronous errors raised by listeners or predicates.

                                                                              Parameter error

                                                                              The thrown error.

                                                                              Parameter errorInfo

                                                                              Additional information regarding the thrown error.

                                                                              Modifiers

                                                                              • @public

                                                                            call signature

                                                                            (error: unknown, errorInfo: ListenerErrorInfo): void;

                                                                              interface ListenerMiddlewareInstance

                                                                              interface ListenerMiddlewareInstance<
                                                                              State = unknown,
                                                                              Dispatch extends ThunkDispatch<State, unknown, AnyAction> = ThunkDispatch<
                                                                              State,
                                                                              unknown,
                                                                              AnyAction
                                                                              >,
                                                                              ExtraArgument = unknown
                                                                              > {}
                                                                              • Modifiers

                                                                                • @public

                                                                              property clearListeners

                                                                              clearListeners: () => void;
                                                                              • Unsubscribes all listeners, cancels running listeners and tasks.

                                                                              property middleware

                                                                              middleware: ListenerMiddleware<State, Dispatch, ExtraArgument>;

                                                                                property startListening

                                                                                startListening: AddListenerOverloads<
                                                                                UnsubscribeListener,
                                                                                State,
                                                                                Dispatch,
                                                                                ExtraArgument
                                                                                >;

                                                                                  property stopListening

                                                                                  stopListening: RemoveListenerOverloads<State, Dispatch>;

                                                                                    interface SerializableStateInvariantMiddlewareOptions

                                                                                    interface SerializableStateInvariantMiddlewareOptions {}
                                                                                    • Options for createSerializableStateInvariantMiddleware().

                                                                                      Modifiers

                                                                                      • @public

                                                                                    property getEntries

                                                                                    getEntries?: (value: any) => [string, any][];
                                                                                    • The function that will be used to retrieve entries from each value. If unspecified, Object.entries will be used. Defaults to undefined.

                                                                                    property ignoreActions

                                                                                    ignoreActions?: boolean;
                                                                                    • Opt out of checking actions. When set to true, other action-related params will be ignored.

                                                                                    property ignoredActionPaths

                                                                                    ignoredActionPaths?: string[];
                                                                                    • An array of dot-separated path strings to ignore when checking for serializability, Defaults to ['meta.arg', 'meta.baseQueryMeta']

                                                                                    property ignoredActions

                                                                                    ignoredActions?: string[];
                                                                                    • An array of action types to ignore when checking for serializability. Defaults to []

                                                                                    property ignoredPaths

                                                                                    ignoredPaths?: string[];
                                                                                    • An array of dot-separated path strings to ignore when checking for serializability, Defaults to []

                                                                                    property ignoreState

                                                                                    ignoreState?: boolean;
                                                                                    • Opt out of checking state. When set to true, other state-related params will be ignored.

                                                                                    property isSerializable

                                                                                    isSerializable?: (value: any) => boolean;
                                                                                    • The function to check if a value is considered serializable. This function is applied recursively to every value contained in the state. Defaults to isPlain().

                                                                                    property warnAfter

                                                                                    warnAfter?: number;
                                                                                    • Execution time warning threshold. If the middleware takes longer than warnAfter ms, a warning will be displayed in the console. Defaults to 32ms.

                                                                                    interface SerializedError

                                                                                    interface SerializedError {}
                                                                                    • Modifiers

                                                                                      • @public

                                                                                    property code

                                                                                    code?: string;

                                                                                      property message

                                                                                      message?: string;

                                                                                        property name

                                                                                        name?: string;

                                                                                          property stack

                                                                                          stack?: string;

                                                                                            interface Slice

                                                                                            interface Slice<
                                                                                            State = any,
                                                                                            CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>,
                                                                                            Name extends string = string
                                                                                            > {}
                                                                                            • The return value of createSlice

                                                                                              Modifiers

                                                                                              • @public

                                                                                            property actions

                                                                                            actions: CaseReducerActions<CaseReducers>;
                                                                                            • Action creators for the types of actions that are handled by the slice reducer.

                                                                                            property caseReducers

                                                                                            caseReducers: SliceDefinedCaseReducers<CaseReducers>;
                                                                                            • The individual case reducer functions that were passed in the reducers parameter. This enables reuse and testing if they were defined inline when calling createSlice.

                                                                                            property getInitialState

                                                                                            getInitialState: () => State;
                                                                                            • Provides access to the initial state value given to the slice. If a lazy state initializer was provided, it will be called and a fresh value returned.

                                                                                            property name

                                                                                            name: Name;
                                                                                            • The slice name.

                                                                                            property reducer

                                                                                            reducer: Reducer<State>;
                                                                                            • The slice's reducer.

                                                                                            interface SyncTaskExecutor

                                                                                            interface SyncTaskExecutor<T> {}
                                                                                            • Modifiers

                                                                                              • @public

                                                                                            call signature

                                                                                            (forkApi: ForkedTaskAPI): T;

                                                                                              interface UnsubscribeListenerOptions

                                                                                              interface UnsubscribeListenerOptions {}
                                                                                              • Modifiers

                                                                                                • @public

                                                                                              property cancelActive

                                                                                              cancelActive?: true;

                                                                                                Type Aliases

                                                                                                type ActionMatchingAllOf

                                                                                                type ActionMatchingAllOf<Matchers extends [Matcher<any>, ...Matcher<any>[]]> =
                                                                                                UnionToIntersection<ActionMatchingAnyOf<Matchers>>;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type ActionMatchingAnyOf

                                                                                                type ActionMatchingAnyOf<Matchers extends [Matcher<any>, ...Matcher<any>[]]> =
                                                                                                ActionFromMatcher<Matchers[number]>;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type Actions

                                                                                                type Actions<T extends keyof any = string> = Record<T, Action>;
                                                                                                • Defines a mapping from action types to corresponding action object shapes.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                  Deprecated

                                                                                                  This should not be used manually - it is only used for internal inference purposes and should not have any further value. It might be removed in the future.

                                                                                                type AsyncThunk

                                                                                                type AsyncThunk<
                                                                                                Returned,
                                                                                                ThunkArg,
                                                                                                ThunkApiConfig extends AsyncThunkConfig
                                                                                                > = AsyncThunkActionCreator<Returned, ThunkArg, ThunkApiConfig> & {
                                                                                                pending: AsyncThunkPendingActionCreator<ThunkArg, ThunkApiConfig>;
                                                                                                rejected: AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig>;
                                                                                                fulfilled: AsyncThunkFulfilledActionCreator<Returned, ThunkArg, ThunkApiConfig>;
                                                                                                typePrefix: string;
                                                                                                };
                                                                                                • A type describing the return value of createAsyncThunk. Might be useful for wrapping createAsyncThunk in custom abstractions.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type AsyncThunkAction

                                                                                                type AsyncThunkAction<
                                                                                                Returned,
                                                                                                ThunkArg,
                                                                                                ThunkApiConfig extends AsyncThunkConfig
                                                                                                > = (
                                                                                                dispatch: GetDispatch<ThunkApiConfig>,
                                                                                                getState: () => GetState<ThunkApiConfig>,
                                                                                                extra: GetExtra<ThunkApiConfig>
                                                                                                ) => Promise<
                                                                                                | ReturnType<AsyncThunkFulfilledActionCreator<Returned, ThunkArg>>
                                                                                                | ReturnType<AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig>>
                                                                                                > & {
                                                                                                abort: (reason?: string) => void;
                                                                                                requestId: string;
                                                                                                arg: ThunkArg;
                                                                                                unwrap: () => Promise<Returned>;
                                                                                                };
                                                                                                • A ThunkAction created by createAsyncThunk. Dispatching it returns a Promise for either a fulfilled or rejected action. Also, the returned value contains an abort() method that allows the asyncAction to be cancelled from the outside.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type AsyncThunkOptions

                                                                                                type AsyncThunkOptions<
                                                                                                ThunkArg = void,
                                                                                                ThunkApiConfig extends AsyncThunkConfig = {}
                                                                                                > = {
                                                                                                /**
                                                                                                * A method to control whether the asyncThunk should be executed. Has access to the
                                                                                                * `arg`, `api.getState()` and `api.extra` arguments.
                                                                                                *
                                                                                                * @returns `false` if it should be skipped
                                                                                                */
                                                                                                condition?(
                                                                                                arg: ThunkArg,
                                                                                                api: Pick<GetThunkAPI<ThunkApiConfig>, 'getState' | 'extra'>
                                                                                                ): MaybePromise<boolean | undefined>;
                                                                                                /**
                                                                                                * If `condition` returns `false`, the asyncThunk will be skipped.
                                                                                                * This option allows you to control whether a `rejected` action with `meta.condition == false`
                                                                                                * will be dispatched or not.
                                                                                                *
                                                                                                * @default `false`
                                                                                                */
                                                                                                dispatchConditionRejection?: boolean;
                                                                                                serializeError?: (x: unknown) => GetSerializedErrorType<ThunkApiConfig>;
                                                                                                /**
                                                                                                * A function to use when generating the `requestId` for the request sequence.
                                                                                                *
                                                                                                * @default `nanoid`
                                                                                                */
                                                                                                idGenerator?: (arg: ThunkArg) => string;
                                                                                                } & IsUnknown<
                                                                                                GetPendingMeta<ThunkApiConfig>,
                                                                                                {
                                                                                                /**
                                                                                                * A method to generate additional properties to be added to `meta` of the pending action.
                                                                                                *
                                                                                                * Using this optional overload will not modify the types correctly, this overload is only in place to support JavaScript users.
                                                                                                * Please use the `ThunkApiConfig` parameter `pendingMeta` to get access to a correctly typed overload
                                                                                                */
                                                                                                getPendingMeta?(
                                                                                                base: {
                                                                                                arg: ThunkArg;
                                                                                                requestId: string;
                                                                                                },
                                                                                                api: Pick<GetThunkAPI<ThunkApiConfig>, 'getState' | 'extra'>
                                                                                                ): GetPendingMeta<ThunkApiConfig>;
                                                                                                },
                                                                                                {
                                                                                                /**
                                                                                                * A method to generate additional properties to be added to `meta` of the pending action.
                                                                                                */
                                                                                                getPendingMeta(
                                                                                                base: {
                                                                                                arg: ThunkArg;
                                                                                                requestId: string;
                                                                                                },
                                                                                                api: Pick<GetThunkAPI<ThunkApiConfig>, 'getState' | 'extra'>
                                                                                                ): GetPendingMeta<ThunkApiConfig>;
                                                                                                }
                                                                                                >;
                                                                                                • Options object for createAsyncThunk.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type AsyncThunkPayloadCreator

                                                                                                type AsyncThunkPayloadCreator<
                                                                                                Returned,
                                                                                                ThunkArg = void,
                                                                                                ThunkApiConfig extends AsyncThunkConfig = {}
                                                                                                > = (
                                                                                                arg: ThunkArg,
                                                                                                thunkAPI: GetThunkAPI<ThunkApiConfig>
                                                                                                ) => AsyncThunkPayloadCreatorReturnValue<Returned, ThunkApiConfig>;
                                                                                                • A type describing the payloadCreator argument to createAsyncThunk. Might be useful for wrapping createAsyncThunk in custom abstractions.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type AsyncThunkPayloadCreatorReturnValue

                                                                                                type AsyncThunkPayloadCreatorReturnValue<
                                                                                                Returned,
                                                                                                ThunkApiConfig extends AsyncThunkConfig
                                                                                                > = MaybePromise<
                                                                                                | IsUnknown<
                                                                                                GetFulfilledMeta<ThunkApiConfig>,
                                                                                                Returned,
                                                                                                FulfillWithMeta<Returned, GetFulfilledMeta<ThunkApiConfig>>
                                                                                                >
                                                                                                | RejectWithValue<
                                                                                                GetRejectValue<ThunkApiConfig>,
                                                                                                GetRejectedMeta<ThunkApiConfig>
                                                                                                >
                                                                                                >;
                                                                                                • A type describing the return value of the payloadCreator argument to createAsyncThunk. Might be useful for wrapping createAsyncThunk in custom abstractions.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type CaseReducer

                                                                                                type CaseReducer<S = any, A extends Action = AnyAction> = (
                                                                                                state: Draft<S>,
                                                                                                action: A
                                                                                                ) => S | void | Draft<S>;
                                                                                                • An *case reducer* is a reducer function for a specific action type. Case reducers can be composed to full reducers using createReducer().

                                                                                                  Unlike a normal Redux reducer, a case reducer is never called with an undefined state to determine the initial state. Instead, the initial state is explicitly specified as an argument to createReducer().

                                                                                                  In addition, a case reducer can choose to mutate the passed-in state value directly instead of returning a new state. This does not actually cause the store state to be mutated directly; instead, thanks to [immer](https://github.com/mweststrate/immer), the mutations are translated to copy operations that result in a new state.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type CaseReducerActions

                                                                                                type CaseReducerActions<CaseReducers extends SliceCaseReducers<any>> = {
                                                                                                [Type in keyof CaseReducers]: CaseReducers[Type] extends {
                                                                                                prepare: any;
                                                                                                }
                                                                                                ? ActionCreatorForCaseReducerWithPrepare<CaseReducers[Type]>
                                                                                                : ActionCreatorForCaseReducer<CaseReducers[Type]>;
                                                                                                };
                                                                                                • Derives the slice's actions property from the reducers options

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type CaseReducers

                                                                                                type CaseReducers<S, AS extends Actions> = {
                                                                                                [T in keyof AS]: AS[T] extends Action ? CaseReducer<S, AS[T]> : void;
                                                                                                };
                                                                                                • A mapping from action types to case reducers for createReducer().

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                  Deprecated

                                                                                                  This should not be used manually - it is only used for internal inference purposes and using it manually would lead to type erasure. It might be removed in the future.

                                                                                                type CaseReducerWithPrepare

                                                                                                type CaseReducerWithPrepare<State, Action extends PayloadAction> = {
                                                                                                reducer: CaseReducer<State, Action>;
                                                                                                prepare: PrepareAction<Action['payload']>;
                                                                                                };
                                                                                                • A CaseReducer with a prepare method.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type Comparer

                                                                                                type Comparer<T> = (a: T, b: T) => number;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type ConfigureEnhancersCallback

                                                                                                type ConfigureEnhancersCallback = (
                                                                                                defaultEnhancers: readonly StoreEnhancer[]
                                                                                                ) => StoreEnhancer[];
                                                                                                • Callback function type, to be used in ConfigureStoreOptions.enhancers

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type EntityId

                                                                                                type EntityId = number | string;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type ForkedTaskExecutor

                                                                                                type ForkedTaskExecutor<T> = AsyncTaskExecutor<T> | SyncTaskExecutor<T>;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type IdSelector

                                                                                                type IdSelector<T> = (model: T) => EntityId;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type ListenerEffect

                                                                                                type ListenerEffect<
                                                                                                Action extends AnyAction,
                                                                                                State,
                                                                                                Dispatch extends ReduxDispatch<AnyAction>,
                                                                                                ExtraArgument = unknown
                                                                                                > = (
                                                                                                action: Action,
                                                                                                api: ListenerEffectAPI<State, Dispatch, ExtraArgument>
                                                                                                ) => void | Promise<void>;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type ListenerMiddleware

                                                                                                type ListenerMiddleware<
                                                                                                State = unknown,
                                                                                                Dispatch extends ThunkDispatch<State, unknown, AnyAction> = ThunkDispatch<
                                                                                                State,
                                                                                                unknown,
                                                                                                AnyAction
                                                                                                >,
                                                                                                ExtraArgument = unknown
                                                                                                > = Middleware<
                                                                                                {
                                                                                                (action: ReduxAction<'listenerMiddleware/add'>): UnsubscribeListener;
                                                                                                },
                                                                                                State,
                                                                                                Dispatch
                                                                                                >;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type PayloadAction

                                                                                                type PayloadAction<P = void, T extends string = string, M = never, E = never> = {
                                                                                                payload: P;
                                                                                                type: T;
                                                                                                } & ([M] extends [never]
                                                                                                ? {}
                                                                                                : {
                                                                                                meta: M;
                                                                                                }) &
                                                                                                ([E] extends [never]
                                                                                                ? {}
                                                                                                : {
                                                                                                error: E;
                                                                                                });
                                                                                                • An action with a string type and an associated payload. This is the type of action returned by createAction() action creators.

                                                                                                  P The type of the action's payload. T the type used for the action type. M The type of the action's meta (optional) E The type of the action's error (optional)

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type PayloadActionCreator

                                                                                                type PayloadActionCreator<
                                                                                                P = void,
                                                                                                T extends string = string,
                                                                                                PA extends PrepareAction<P> | void = void
                                                                                                > = IfPrepareActionMethodProvided<
                                                                                                PA,
                                                                                                _ActionCreatorWithPreparedPayload<PA, T>,
                                                                                                IsAny<
                                                                                                P,
                                                                                                ActionCreatorWithPayload<any, T>,
                                                                                                IsUnknownOrNonInferrable<
                                                                                                P,
                                                                                                ActionCreatorWithNonInferrablePayload<T>,
                                                                                                IfVoid<
                                                                                                P,
                                                                                                ActionCreatorWithoutPayload<T>,
                                                                                                IfMaybeUndefined<
                                                                                                P,
                                                                                                ActionCreatorWithOptionalPayload<P, T>,
                                                                                                ActionCreatorWithPayload<P, T>
                                                                                                >
                                                                                                >
                                                                                                >
                                                                                                >
                                                                                                >;
                                                                                                • An action creator that produces actions with a payload attribute.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type PrepareAction

                                                                                                type PrepareAction<P> =
                                                                                                | ((...args: any[]) => {
                                                                                                payload: P;
                                                                                                })
                                                                                                | ((...args: any[]) => {
                                                                                                payload: P;
                                                                                                meta: any;
                                                                                                })
                                                                                                | ((...args: any[]) => {
                                                                                                payload: P;
                                                                                                error: any;
                                                                                                })
                                                                                                | ((...args: any[]) => {
                                                                                                payload: P;
                                                                                                meta: any;
                                                                                                error: any;
                                                                                                });
                                                                                                • A "prepare" method to be used as the second parameter of createAction. Takes any number of arguments and returns a Flux Standard Action without type (will be added later) that *must* contain a payload (might be undefined).

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type SliceActionCreator

                                                                                                type SliceActionCreator<P> = PayloadActionCreator<P>;
                                                                                                • An action creator attached to a slice.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                  Deprecated

                                                                                                  please use PayloadActionCreator directly

                                                                                                type SliceCaseReducers

                                                                                                type SliceCaseReducers<State> = {
                                                                                                [K: string]:
                                                                                                | CaseReducer<State, PayloadAction<any>>
                                                                                                | CaseReducerWithPrepare<State, PayloadAction<any, string, any, any>>;
                                                                                                };
                                                                                                • The type describing a slice's reducers option.

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type TaskCancelled

                                                                                                type TaskCancelled = {
                                                                                                readonly status: 'cancelled';
                                                                                                readonly error: TaskAbortError;
                                                                                                };
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type TaskRejected

                                                                                                type TaskRejected = {
                                                                                                readonly status: 'rejected';
                                                                                                readonly error: unknown;
                                                                                                };
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type TaskResolved

                                                                                                type TaskResolved<T> = {
                                                                                                readonly status: 'ok';
                                                                                                readonly value: T;
                                                                                                };
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type TaskResult

                                                                                                type TaskResult<Value> = TaskResolved<Value> | TaskRejected | TaskCancelled;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type TypedAddListener

                                                                                                type TypedAddListener<
                                                                                                State,
                                                                                                Dispatch extends ReduxDispatch<AnyAction> = ThunkDispatch<
                                                                                                State,
                                                                                                unknown,
                                                                                                AnyAction
                                                                                                >,
                                                                                                ExtraArgument = unknown,
                                                                                                Payload = ListenerEntry<State, Dispatch>,
                                                                                                T extends string = 'listenerMiddleware/add'
                                                                                                > = BaseActionCreator<Payload, T> &
                                                                                                AddListenerOverloads<PayloadAction<Payload, T>, State, Dispatch, ExtraArgument>;
                                                                                                • A "pre-typed" version of addListenerAction, so the listener args are well-typed

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type TypedRemoveListener

                                                                                                type TypedRemoveListener<
                                                                                                State,
                                                                                                Dispatch extends ReduxDispatch<AnyAction> = ThunkDispatch<
                                                                                                State,
                                                                                                unknown,
                                                                                                AnyAction
                                                                                                >,
                                                                                                Payload = ListenerEntry<State, Dispatch>,
                                                                                                T extends string = 'listenerMiddleware/remove'
                                                                                                > = BaseActionCreator<Payload, T> &
                                                                                                AddListenerOverloads<
                                                                                                PayloadAction<Payload, T>,
                                                                                                State,
                                                                                                Dispatch,
                                                                                                any,
                                                                                                UnsubscribeListenerOptions
                                                                                                >;
                                                                                                • A "pre-typed" version of removeListenerAction, so the listener args are well-typed

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type TypedStartListening

                                                                                                type TypedStartListening<
                                                                                                State,
                                                                                                Dispatch extends ReduxDispatch<AnyAction> = ThunkDispatch<
                                                                                                State,
                                                                                                unknown,
                                                                                                AnyAction
                                                                                                >,
                                                                                                ExtraArgument = unknown
                                                                                                > = AddListenerOverloads<UnsubscribeListener, State, Dispatch, ExtraArgument>;
                                                                                                • A "pre-typed" version of middleware.startListening, so the listener args are well-typed

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type TypedStopListening

                                                                                                type TypedStopListening<
                                                                                                State,
                                                                                                Dispatch extends ReduxDispatch<AnyAction> = ThunkDispatch<
                                                                                                State,
                                                                                                unknown,
                                                                                                AnyAction
                                                                                                >
                                                                                                > = RemoveListenerOverloads<State, Dispatch>;
                                                                                                • A "pre-typed" version of middleware.stopListening, so the listener args are well-typed

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                type UnsubscribeListener

                                                                                                type UnsubscribeListener = (unsubscribeOptions?: UnsubscribeListenerOptions) => void;
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type Update

                                                                                                type Update<T> = {
                                                                                                id: EntityId;
                                                                                                changes: Partial<T>;
                                                                                                };
                                                                                                • Modifiers

                                                                                                  • @public

                                                                                                type ValidateSliceCaseReducers

                                                                                                type ValidateSliceCaseReducers<S, ACR extends SliceCaseReducers<S>> = ACR & {
                                                                                                [T in keyof ACR]: ACR[T] extends {
                                                                                                reducer(s: S, action?: infer A): any;
                                                                                                }
                                                                                                ? {
                                                                                                prepare(...a: never[]): Omit<A, 'type'>;
                                                                                                }
                                                                                                : {};
                                                                                                };
                                                                                                • Used on a SliceCaseReducers object. Ensures that if a CaseReducer is a CaseReducerWithPrepare, that the reducer and the prepare function use the same type of payload.

                                                                                                  Might do additional such checks in the future.

                                                                                                  This type is only ever useful if you want to write your own wrapper around createSlice. Please don't use it otherwise!

                                                                                                  Modifiers

                                                                                                  • @public

                                                                                                Package Files (20)

                                                                                                Dependencies (4)

                                                                                                Dev Dependencies (48)

                                                                                                Peer Dependencies (2)

                                                                                                Badge

                                                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@reduxjs/toolkit.

                                                                                                • Markdown
                                                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@reduxjs/toolkit)
                                                                                                • HTML
                                                                                                  <a href="https://www.jsdocs.io/package/@reduxjs/toolkit"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>