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

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

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

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 :

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

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