问题
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 very well
},
clearUser: (state) => {},
},
});
export const { setUser, clearUser } = userSlice.actions;
export const currentUser = (state) => state.user.currentUser;
export default userSlice.reducer;
here is redux store
import { configureStore } from "@reduxjs/toolkit";
import userReducer from "../features/user/userSlice";
export default configureStore({
reducer: {
user: userReducer,
},
});
来源:https://stackoverflow.com/questions/65764486/why-reducer-function-return-only-proxy-redux-toolkit