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

618
Views
Javascript react - using createSlice and encountering 'property assignment expected' / 'Declaration or statement expected'

I'm trying for the first time to create a slice using react, and am encountering the following issue. My 'createSlice' looks as follows:

const querySlice = createSlice({
  name: 'querySlice',
  initialState,  
  reducers: {
    setOutputTable: (state, action: PayloadAction<string>) => {
      state.outputTable = action.payload;      
    },
    setInputTable: (state, action: PayloadAction<string>) => {
      state.inputTable = action.payload;      
    },
    setSelectColumns: (state, action: PayloadAction<string>) => {
      state.selectColumns = action.payload;      
    },
    reset() {
      return initialState;
    },
  },  
)};

Using VS Code, the bottom parentheses and curly bracket are marked for error, with the issues being 1) Property assignment expected. 2) Declaration or statement expected.

Does anyone recognize what might be amiss in my code? Thanks for any suggestions.

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Rewrite:

const querySlice = createSlice({
  name: 'querySlice',
  initialState,  
  reducers: {
    setOutputTable: (state, action: PayloadAction<string>) => {
      state.outputTable = action.payload;      
    },
    setInputTable: (state, action: PayloadAction<string>) => {
      state.inputTable = action.payload;      
    },
    setSelectColumns: (state, action: PayloadAction<string>) => {
      state.selectColumns = action.payload;      
    },
    reset: () => {
      state = initialState;
    },
  },  
)};

about 4 years ago · Santiago Gelvez Report

0

In your last line, it should be }), not )}

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