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

Module not found: Can't resolve 'swiper' in Reactjs [Solved]
Publish date: 2021-10-03 | Comments: 1

Tag: React js

TypeError: Cannot read properties of null (reading 'scrollTop') in jest
Publish date: 2022-09-08 | Comments: 1

Tag: React js

Could not be processed as an image because it has an invalid content type
Publish date: 2021-12-08 | Comments: 0

Tag: React js

[solved] Reactjs is not updating the props
Publish date: 2022-02-04 | 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

How to implement SSO with React and ASP.NET Core Web API ?
Publish date: 2022-11-03 | Comments: 0

Tag: React js