Use null instead of '' in ternary expression

A blank string ('') resolves to <span></span> which produces a warning when place inside a <tr>
This commit is contained in:
Kale 2015-11-23 06:38:08 -07:00
parent 7ea1d15197
commit b74e53c3ca
1 changed files with 1 additions and 1 deletions

View File

@ -30,7 +30,7 @@ React.createElement("div", {id: if (condition) { 'msg' }}, "Hello World!");
That's not valid JS. You probably want to make use of a ternary expression:
```js
ReactDOM.render(<div id={condition ? 'msg' : ''}>Hello World!</div>, mountNode);
ReactDOM.render(<div id={condition ? 'msg' : null}>Hello World!</div>, mountNode);
```
If a ternary expression isn't robust enough, you can use `if` statements outside of your JSX to determine which components should be used: