Home > Enterprise >  Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-e
Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-e

Time:01-16

I am tryring to create a reducer for my Redux app but the following code keeps bringing up this error

Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions

const reducer = combineReducers({
    answers: (state:string[] = [], action) => {
        const newState:string[] = state
        if(action.type == "add") {
            newState.push(action.item)
        }
        if(action.type == "reset"){
            newState == [];
        }
        console.log(newState)
        return newState
    }
})

I am already returning a value (newState) so I am not sure what I am doing wrong

CodePudding user response:

newState == [] is a condition, not an assignment

  •  Tags:  
  • Related