Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import { finished } from "stream";
  2.  
  3. import React, {Component, useEffect } from 'react'
  4. import {fetchSingleEmployee} from "../redux/actions";
  5. import {connect, useDispatch, useSelector} from 'react-redux'
  6.  
  7.  
  8. const EmployeePage = props => {
  9. const {employee, isFetching} = this.props;
  10. return (
  11. <div>
  12. {
  13. isFetching ? (
  14. <span>Loading...</span>
  15.  
  16. ) : (
  17. <div>
  18. <h2>{employee.first_name} {employee.hasMeet}</h2>
  19. </div>
  20. )
  21. }
  22. </div>
  23. )
  24. }
  25.  
  26. const ConnectedEmployeePage = props => {
  27. const { match: { params: id }} = props;
  28. const dispatch = useDispatch();
  29.  
  30. useEffect(() => {
  31. dispatch(fetchSingleEmployee(id))
  32. }, [id])
  33.  
  34. const employee = useSelector(state => state.employees.find(employee => employee.id === id))
  35. const isFetching = useSelector(state => state.isFetchingEmployees)
  36.  
  37. return <EmployeePage employee={employee} isFetching={}/>
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement