redux-toolkit

Redux / RTK: create enhancer for one slice?

有些话、适合烂在心里 提交于 2021-02-05 11:57:16
问题 In one of the slices in my Redux / RTK store, all I need to to do to make the slice do its job is to create an entity adapter using createEntityAdapter() and export the setAll CRUD function. So far, so simple - thanks to RTK :-) However, when data for that slice comes in, I need to "augment" it (or "enhance" it, as Redux docs call it), i.e. add further information derived from data coming in, for example for formatted data displayde in the UI (contrived example). I created an enhancer for

Redux / RTK: create enhancer for one slice?

孤者浪人 提交于 2021-02-05 11:57:05
问题 In one of the slices in my Redux / RTK store, all I need to to do to make the slice do its job is to create an entity adapter using createEntityAdapter() and export the setAll CRUD function. So far, so simple - thanks to RTK :-) However, when data for that slice comes in, I need to "augment" it (or "enhance" it, as Redux docs call it), i.e. add further information derived from data coming in, for example for formatted data displayde in the UI (contrived example). I created an enhancer for

Why reducer function return only proxy? redux/toolkit

喜夏-厌秋 提交于 2021-01-29 10:35:32
问题 My reducer function in state parameter (payload) returns the only proxy: Proxy {i: 0, A: {…}, P: false, I: false, D: {…}, …} [[Handler]]: null [[Target]]: null [[IsRevoked]]: true My slice where is state proxy: import { createSlice } from "@reduxjs/toolkit"; export const userSlice = createSlice({ name: "user", initialState: { currentUser: { loggined: false, isAdmin: false, jwt: false, }, }, reducers: { setUser: (state, payload) => { console.log(state); // here is problem, but payload works

Redux Toolkit - I can't update Slice state?

爱⌒轻易说出口 提交于 2021-01-29 08:58:33
问题 I wanna update the state and tried few ways to do that, but I can't. First, I got a problem with fetching state, as a result, I got proxy, not a state. That is fixed by the current() function by the redux toolkit. Next, where I have a problem is mutation main slice state. Here is a reducer for mutating. reducers: { setUser: (state, payload) => { console.log("before", current(state)); //init state state.currentUser = { ...state.currentUser, loggined: true, }; console.log("after", current(state

Property 'then' does not exist on type 'AsyncThunkAction' Redux-toolkit

旧城冷巷雨未停 提交于 2021-01-28 19:07:20
问题 I can't seem to receive a Promise from createAsyncThunk function from Redux-toolkit I'm fairly new to Typescript and I'm struggling to figure out why it's giving me Property 'then' does not exist on type 'AsyncThunkAction<Student, number, {}>' error even though the promise does get returned if I remove the typing. Here is my createAsyncThunk f-n export const getStudentByIdRequest = createAsyncThunk<Student, number>( 'student/getStudentByIdRequest', async (id, { rejectWithValue }) => { try {

Getting an error “A non-serializable value was detected in the state” when using redux toolkit - but NOT with normal redux

僤鯓⒐⒋嵵緔 提交于 2020-11-28 04:43:04
问题 I am trying to switch an app I am building over to use Redux Toolkit, and have noticed this error coming up as soon as I switched over to configureStore from createStore: A non-serializable value was detected in the state, in the path: `varietals.red.0`. Value:, Varietal { "color": "red", "id": "2ada6486-b0b5-520e-b6ac-b91da6f1b901", "isCommon": true, "isSelected": false, "varietal": "bordeaux blend", }, Take a look at the reducer(s) handling this action type: TOGGLE_VARIETAL. (See https:/

Getting an error “A non-serializable value was detected in the state” when using redux toolkit - but NOT with normal redux

為{幸葍}努か 提交于 2020-11-28 04:39:48
问题 I am trying to switch an app I am building over to use Redux Toolkit, and have noticed this error coming up as soon as I switched over to configureStore from createStore: A non-serializable value was detected in the state, in the path: `varietals.red.0`. Value:, Varietal { "color": "red", "id": "2ada6486-b0b5-520e-b6ac-b91da6f1b901", "isCommon": true, "isSelected": false, "varietal": "bordeaux blend", }, Take a look at the reducer(s) handling this action type: TOGGLE_VARIETAL. (See https:/

Getting an error “A non-serializable value was detected in the state” when using redux toolkit - but NOT with normal redux

送分小仙女□ 提交于 2020-11-28 04:39:44
问题 I am trying to switch an app I am building over to use Redux Toolkit, and have noticed this error coming up as soon as I switched over to configureStore from createStore: A non-serializable value was detected in the state, in the path: `varietals.red.0`. Value:, Varietal { "color": "red", "id": "2ada6486-b0b5-520e-b6ac-b91da6f1b901", "isCommon": true, "isSelected": false, "varietal": "bordeaux blend", }, Take a look at the reducer(s) handling this action type: TOGGLE_VARIETAL. (See https:/

Getting an error “A non-serializable value was detected in the state” when using redux toolkit - but NOT with normal redux

守給你的承諾、 提交于 2020-11-28 04:39:40
问题 I am trying to switch an app I am building over to use Redux Toolkit, and have noticed this error coming up as soon as I switched over to configureStore from createStore: A non-serializable value was detected in the state, in the path: `varietals.red.0`. Value:, Varietal { "color": "red", "id": "2ada6486-b0b5-520e-b6ac-b91da6f1b901", "isCommon": true, "isSelected": false, "varietal": "bordeaux blend", }, Take a look at the reducer(s) handling this action type: TOGGLE_VARIETAL. (See https:/