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

165
Views
I cannot define my state in reduxjs/toolkit as Array

I need to define in my app state as empty Array initially and later it will be an Array of objects.

I have object type defined like below:

export type LuxmedBenefitUserType= {
  id: number;
  name: string;
  lastName: string;
  profileName: string;
  contractForm: string;
  userRelation: string;
  offerType: string;
  totalPrice: number;
  employerCost: number;
  employeeCost: number;
};

Then I define createSlice initial state as below.

export const addEditLuxmedBenefitSystemsSlice = createSlice({
  name: 'addEditLuxmedSlice',
  initialState: [] as LuxmedBenefitUserType[],
  reducers: {
    addEditBenefits: (state, action) => {
      const {id} = action.payload;
      if(!state) {state.push(action.payload)};
      if(state) {state.map = (user)=>{
    user.id === id && return action.payload
  }}; 
    },
  },
});

But with this I cannot procee with .push , it throws me an error :

any
Property 'push' does not exist on type 'never'.

Can You please let me know what I do wrong here and that state will allow me to use .push method ?

thanks

about 4 years ago · Santiago Trujillo
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!