Why do I get these errors with my ternary operator?


This is what I get in the console: Unnecessary use of boolean literals in conditional expression no-unneeded-ternary.

I’m just trying to do a ternary operator that validates the state of a game and only if the game has started and the user.role is equal with player I disable the button. I am using reactjs and with the help of FormField hook I am making a form.

disabled ={(game.state === 'started' && user.role === PLAYER) ? true : false} 

Source: JavaSript – Stack Overflow

October 28, 2021
Category : News
Tags: conditional-operator | conditional-statements | javascript | reactjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.