Created
May 25, 2017 05:59
-
-
Save jackfranklin/623ae418f9cad0edc4146513720fe186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const User = props => <p>This would render a user</p> | |
class Users extends React.Component { | |
// has this.state.users which is an array from an API | |
// not gonna bother writing the code to fetch that... | |
render() { | |
return ( | |
<div> | |
<h2>The users</h2> | |
<ul> | |
{this.state.users.map(u => ( | |
<li key={u.id}><User user={user} /></li> | |
))} | |
</ul> | |
</div> | |
) | |
} | |
} | |
// vs... | |
class Users extends React.Component { | |
// has this.state.users which is an array from an API | |
// not gonna bother writing the code to fetch that... | |
renderUsers() { | |
this.state.users.map(u => ( | |
<li key={u.id}><User user={user} /></li> | |
)) | |
} | |
render() { | |
return ( | |
<div> | |
<h2>The users</h2> | |
<ul>{this.renderUsers()}</ul> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment