user image

Mohamed Atef
Published in : 2021-10-30

Unexpected mix of '&&' and '||' Reactjs

React js

if you can see this warning in your project console you can figure it out by sorting your condition in (  ), so if your code looks like

!this.state.pagesArray.includes(lastPage-1) && lastPage !== 0 || !this.state.pagesArray.includes(lastPage) && lastPage !== 0?

you will need to add (  ) for the first condition then (  ) for the last condition so the code will be 

(!this.state.pagesArray.includes(lastPage-1) && lastPage !== 0) || (!this.state.pagesArray.includes(lastPage) && lastPage !== 0)?

That's all, I found this issue & I wanted to share it with other developers :)
Thanks

Comments

There is no comments yet

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

[solved] Reactjs is not updating the props
Publish date: 2022-02-04 | Comments: 2

Tag: React js

npm install @mui/material returns error
Publish date: 2022-04-02 | Comments: 1

Tag: React js

[solved] Expected a conditional expression and instead saw an assignment
Publish date: 2021-11-29 | Comments: 0

Tag: React js

[solved] Render/Show a custom option in Autocomplete Material UI?
Publish date: 2021-12-22 | Comments: 2

Tag: React js

Export 'Switch' (imported as 'Switch') was not found in 'react-router-dom'
Publish date: 2022-04-02 | Comments: 2

Tag: React js

import link as router link from 'react-router-dom' Reactjs
Publish date: 2021-09-30 | Comments: 3

Tag: React js