False in JSX

Here's how false renders in different situations:

Renders as id="false":

ReactDOM.render(<div id={false} />, mountNode);

String "false" as input value:

ReactDOM.render(<input value={false} />, mountNode);

No child:

ReactDOM.render(<div>{false}</div>, mountNode);

The reason why this one doesn't render as the string "false" as a div child is to allow the more common use-case: <div>{x > 1 && 'You have more than one item'}</div>.

doc_React
2016-06-23 03:31:58
Comments
Leave a Comment

Please login to continue.