Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading