I am trying to dispatching an circular object using dispatch(addClient(conversationsClient)) to the redux toolkit slice once I get the result I can log it but once I assign it the sore I having the issue.
//it's Dumay data to explain my issue
const conversationsClient = [{}];
a[0].a = a;
a.push(a);
const chatSlice = createSlice({
name: 'chatSlice',
initialState: initialState,
reducers: {
addClient: (state, action: PayloadAction<any>) => {
console.log("I can see the proper object", action.payload);
state.client = action.payload; //here I am getting the exception
}
}
});
dispatch(addClient(conversationsClient))
I am getting the following result Uncaught (in promise) RangeError: Maximum call stack size exceeded at StateMachine.get [as state] (state-machine.js:575) at trackProperties
I've tried to used the following package : https://www.npmjs.com/package/flatted may any work around to solve this issue because I am looking to use the object in many components