Warning: Received `false` for a non-boolean attribute. How do I pass a boolean for a custom boolean attribute?

desilijic picture desilijic · Apr 11, 2018 · Viewed 51.6k times · Source
Warning: Received `false` for a non-boolean attribute `comingsoon`.

If you want to write it to the DOM, pass a string instead: 
comingsoon="false" or comingsoon={value.toString()}.

How do I pass a boolean in a custom attribute for React?

I'm using styled-components and passing the attribute through the component. Here is a picture of how I'm passing the attr.

passing boolean custom attr as "comingsoon"

styled-components css props

Answer

Frank Lin picture Frank Lin · Jun 8, 2018

Try this instead:

comingsoon={value ? 1 : 0}