Skip to content

Commit

Permalink
Use null instead of '' in ternary expression
Browse files Browse the repository at this point in the history
A blank string ('') resolves to <span></span> which produces a warning when place inside a <tr>
  • Loading branch information
kryogenic committed Nov 23, 2015
1 parent 7ea1d15 commit b74e53c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/tips/03-if-else-in-JSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b74e53c

Please sign in to comment.