Merge pull request #5533 from kryogenic/patch-1

Use null instead of '' in ternary expression
(cherry picked from commit d01188133e)
This commit is contained in:
Paul O’Shannessy
2015-12-01 11:53:06 -08:00
parent ef20f03429
commit f974581a6a
+1 -1
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: