Created
July 8, 2017 07:56
-
-
Save panzerdp/9cb1f68eded62db500f8d4aa2c3d1264 to your computer and use it in GitHub Desktop.
Extract user data to component map method
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
class App extends React.Component { | |
//.... | |
render() { | |
return ( | |
<div> | |
<h1>Users</h1> | |
<ul> | |
{this.state.users.map(this.userDataToComponent)} | |
</ul> | |
</div> | |
); | |
} | |
userDataToComponent = user => { | |
return ( | |
<UserListItem | |
key={user.id} | |
user={user} | |
onClick={this.deleteUser} | |
/> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment