How to log state.data in reducer function?
Consider the following Redux Toolkit state:
const initialState = {
data: [],
};
const dataSlice = createSlice({
name: "data",
initialState,
reducers: {
setData: (state, action: PayloadAction<DataType[]>) => {
console.log("state.data", state.data);
},
},
});
// state.data Proxy(Object) {type_: 0, scope_: {…}, modified_: false, finalized_: false, assigned_: {…}, …}
I'm unable to log state data in console
Comments
If you want to see the state.data you'll have to do console.log as follows:
reference: