Skip to content

Instantly share code, notes, and snippets.

@edrpls
Created July 25, 2019 18:59
Show Gist options
  • Save edrpls/1ae73fc539e315cf3bcdc7cb6f8fbf87 to your computer and use it in GitHub Desktop.
Save edrpls/1ae73fc539e315cf3bcdc7cb6f8fbf87 to your computer and use it in GitHub Desktop.
// Clients.jsx
import React from 'react';
class Clients extends React.Component {
// Request the server data
componentDidMount() {
this.props.getClients();
}
_reverseOrder = () => this.props.toggleSorting();
render() {
return (
<div>
<button type="button" onClick={this._reverseOrder}>
Reverse order
</button>
<ul>
{/* We now use the clients array that comes from the props */}
{this.props.clients.map(client => <li key={client.id}>{client.name}</li>)}
</ul>
</div>
);
}
}
export default Clients;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment