Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

620
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda