Guest User

Untitled

a guest
Jul 4th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, {Component} from 'react';
  2. import {connect} from 'react-redux';
  3. import {fetchUsersSuccess, fetchUsers, fetchUsersFailure, deleteUser, deleteUserSuccess, deleteUserFailure, reset, showModal} from "../actions/userActions";
  4. import UserList from "../components/UserList";
  5.  
  6. const mapStateToProps = (state) => {
  7.     return {
  8.         userList: state.user.userList
  9.     };
  10. }
  11.  
  12. const mapDispatchToProps = (dispatch) => {
  13.     return {
  14.         fetchUsers: () => {console.log("FetchUsers1: "+new Date().getTime());
  15.             dispatch(fetchUsers()).then((response) => {
  16.                 !response.error ? dispatch(fetchUsersSuccess(response.payload.data)) : dispatch(fetchUsersFailure(response.payload.data));
  17.             });
  18.         },
  19.         refreshUsers: (id) => {
  20.             dispatch(reset());
  21.             dispatch(fetchUsers()).then((response) => {
  22.                 !response.error ? dispatch(fetchUsersSuccess(response.payload.data)) : dispatch(fetchUsersFailure(response.payload.data));
  23.             });
  24.         }
  25.     }
  26. }
  27.  
  28. export default connect(mapStateToProps, mapDispatchToProps)(UserList);
Advertisement
Add Comment
Please, Sign In to add comment