mirror of
https://github.com/facebook/react.git
synced 2026-02-24 12:43:00 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user