Browse Source

Avoid unnecessary ternary

main
Dan Abramov 7 years ago
committed by GitHub
parent
commit
c9e99c8ae6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      content/docs/conditional-rendering.md

13
content/docs/conditional-rendering.md

@ -92,12 +92,13 @@ class LoginControl extends React.Component {
render() { render() {
const isLoggedIn = this.state.isLoggedIn; const isLoggedIn = this.state.isLoggedIn;
let button;
const button = isLoggedIn ? (
<LogoutButton onClick={this.handleLogoutClick} /> if (isLoggedIn) {
) : ( button = <LogoutButton onClick={this.handleLogoutClick} />;
<LoginButton onClick={this.handleLoginClick} /> } else {
); button = <LoginButton onClick={this.handleLoginClick} />
}
return ( return (
<div> <div>

Loading…
Cancel
Save