Merge pull request #739 from acelaya-forks/feature/rtk-errors

Changed how errors are serialized by async thunks
This commit is contained in:
Alejandro Celaya 2022-11-13 18:36:10 +01:00 committed by GitHub
commit ee7a091586
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,12 @@
import { createAsyncThunk as baseCreateAsyncThunk, AsyncThunkPayloadCreator } from '@reduxjs/toolkit'; import { createAsyncThunk as baseCreateAsyncThunk, AsyncThunkPayloadCreator } from '@reduxjs/toolkit';
import { identity } from 'ramda';
import { ShlinkState } from '../../container/types'; import { ShlinkState } from '../../container/types';
export const createAsyncThunk = <Returned, ThunkArg>( export const createAsyncThunk = <Returned, ThunkArg>(
typePrefix: string, typePrefix: string,
payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, { state: ShlinkState }>, payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, { state: ShlinkState, serializedErrorType: any }>,
) => baseCreateAsyncThunk(typePrefix, payloadCreator); ) => baseCreateAsyncThunk(
typePrefix,
payloadCreator,
{ serializeError: identity },
);