React, redux-toolkit

I’m getting the following error on load my page:
Uncaught (in promise) RangeError: Maximum call stack size exceeded at new Set ()

I have a slice with logic to store an editor instance, it looks like this:

import { createSlice } from '@reduxjs/toolkit'
import { RootState } from 'redux-store/index'

const initialState: any = null

const editorClientSlice = createSlice({
  name: 'editorClient',
  initialState,
  reducers: {
    setEditorClient: (_, { payload }) => payload,
  },
})

export const { setEditorClient } = editorClientSlice.actions
export const editorClient = (state: RootState) => state.editorClient
export default editorClientSlice.reducer

The custom hook that contains initializing the instance of the EditorClient class:

import { EditorClient } from '@optimalux/js-agent/src/editor_client'
import { useDispatch } from 'react-redux'
import { setEditorClient } from 'redux-store/slices/editorClientSlices/editorClientSlice'

export const useEditor = () => {
  const dispatch = useDispatch()

  const initEditor = () => {
    const editorClient = new EditorClient()
    dispatch(setEditorClient(editorClient))
  }

  return {
    initEditor,
  }
}

And the page, where I call the initEditor function:

const ExperimentSettings = memo(function ExperimentSettings() {
  const { initEditor } = useEditor()
  const editor = useAppSelector(editorClient)

  useEffectOnce(() => {
    if (editor === null) {
      initEditor()
    }
  })
...... other lines of code ......

What am I doing wrong? Any advice please…

Hi @Undefined

The error Maximum call stack size exceeded mean that you are invoking something in an infinite loop.

I don’t see new Set () constructor anywhere in your code so maybe it is from some other part of the code?