`if-else` statements don't work inside JSX, since JSX is really just sugar for functions:
`if-else` statements don't work inside JSX. This is because JSX is just syntactic sugar for function calls and object construction. Take this basic example:
Which means `<div id={if (true){ 'msg' }}>Hello World!</div>` doesn't make sense, as (if it worked) it would be compiled down to something like this `React.DOM.div({id: if (true){ 'msg' }}, "Hello World!")`, which isn't valid JS.
This means that `if` statements don't fit in. Take this example:
```js
/** @jsx React.DOM */
// This JSX:
<divid={if(condition){'msg'}}>Hello World!</div>
// Is transformed to this JS:
React.DOM.div({id: if (condition) { 'msg' }}, "Hello World!");
```
What you're searching for is ternary expression:
That's not valid JS. You probably want to make use of a ternary expression: