Use null instead of '' in ternary expression
A blank string ('') resolves to <span></span> which produces a warning when place inside a <tr>
Kale committed
Nov 23, 2015 at 06:38 UTC
b74e53c3ca730f1997dbfb53555348aeaa6db2ee
1 file changed
+1
-1
docs/tips/03-if-else-in-JSX.md
+1
-1
@@ -30,7 +30,7 @@ React.createElement("div", {id: if (condition) { 'msg' }}, "Hello World!");
30
That's not valid JS. You probably want to make use of a ternary expression:
31
32
```js
33
-ReactDOM.render(<div id={condition ? 'msg' : ''}>Hello World!</div>, mountNode);
33
+ReactDOM.render(<div id={condition ? 'msg' : null}>Hello World!</div>, mountNode);
34
```
35
36
If a ternary expression isn't robust enough, you can use `if` statements outside of your JSX to determine which components should be used: