Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
Illegal constructor using useSelector from react-redux lib?

Why do I get this error?

TypeError: Illegal constructor

Beow is my store.js file:

import { configureStore, combineReducers } from '@reduxjs/toolkit'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import formReducer from './features/form/form'
import modalReducer from './features/modal-status/modal'

const persistConfig = {
  key: 'root',
  storage,
}

const rootReducer = combineReducers({
  modal: modalReducer,
  process: formReducer
})

const persistedReducer = persistReducer(persistConfig, rootReducer)

export default function createStore() {
  let store = configureStore({
    reducer: persistedReducer,
    devTools: true
  })
  let persistor = persistStore(store)
  return { store, persistor }
}

Below is my form reducer code:

import { createSlice } from '@reduxjs/toolkit'

export const formSlice = createSlice({
  name: 'process',
  initialState: {
    type: 'UNKNOWN',
    isLogined: false,
    username: null,
    clientId: null,
    avatarUri: null
  },
  reducers: {
    process(state, action) {
      if(action.payload.type == 'LOGIN') {
        if('username' in action.payload && 'clientId' in action.payload && 'avatarUri' in action.payload) {
          return {
            ...state,
            type: 'LOGIN',
            isLogined: action.payload.isLogined,
            username: action.payload['username'],
            clientId: action.payload['clientId'],
            avatarUri: action.payload['avatarUri'],
          }
        }
      } else {
        return state
      }
    }
  }
})

export const { process } = formSlice.actions
export default formSlice.reducer

And in react component I used useSelector hook like below:

  const isLogin = useSelector(state => state.process.isLogined)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!