Guest User

Untitled

a guest
Jul 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. class EmployeesList extends Component {
  2. render() {
  3. return (
  4. <div className="EmployeesList">
  5. {this.state.employees.map((employee) => (
  6. <div className="Employee">
  7. {this._renderAvatar(pick(employee, ['name', 'initials', 'photoUrl']))}
  8. </div>
  9. ))}
  10. </div>
  11. );
  12. }
  13.  
  14. constructor() {}
  15.  
  16. state = {
  17. employees: [],
  18. pendingRequest: false,
  19. };
  20.  
  21. getDerivedStateFromProps() {}
  22.  
  23. componentDidMount() {
  24. this.setState(() => ({pendingRequest: true}));
  25. Ajax.get('/employees')
  26. .then((response) => this.setState({
  27. employees: response.data,
  28. pendingRequest: false,
  29. }));
  30. }
  31.  
  32. shouldComponentUpdate() {}
  33.  
  34. componentDidUpdate() {}
  35.  
  36. _borderColor = 'blue';
  37. _staticEmployeeStuff = {};
  38.  
  39. _handleAvatarClick = () => {};
  40.  
  41. _renderAvatar = (props) => {
  42. const {name, initials, photoUrl} = props;
  43. const imgUrl = photoUrl ? photoUrl : INITIALS_BASE + initials;
  44. return (
  45. <img alt={name} onClick={this._handleAvatarClick} src={imgUrl} />
  46. );
  47. };
  48. }
Add Comment
Please, Sign In to add comment