Skip to content

Commit 68621e9

Browse files
gaearonchrisvfritz
authored andcommitted
Use if statement instead of ternary (#371)
* Use if statement instead of ternary * Make it a little more compact
1 parent a56d0eb commit 68621e9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/guide/comparison.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,21 @@ With React's JSX, there are minor differences from HTML, such as using `classNam
5555
Take this example below:
5656

5757
``` jsx
58-
render () {
59-
const { items } = this.props
60-
58+
render() {
59+
let { items } = this.props
60+
61+
let children
62+
if (items.length > 0) {
63+
children = items.map(item =>
64+
<li key={item.id}>{item.name}</li>
65+
)
66+
} else {
67+
children = <p>No items found.</p>
68+
}
69+
6170
return (
6271
<div className='list-container'>
63-
{items.length
64-
? <ul>
65-
{items.map(item => <li key={item.id}>{item.name}</li>)}
66-
</ul>
67-
: <p>No items found.</p>
68-
}
72+
{children}
6973
</div>
7074
)
7175
}

0 commit comments

Comments
 (0)