Guest User

Untitled

a guest
Apr 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. class User extends Component {
  2.  
  3. render() {
  4. return <div>{this.props.user.name}</div>
  5. }
  6.  
  7. componentWillMountDidMount() {
  8. this.getUser();
  9. }
  10.  
  11. async getUser() {
  12. try {
  13. const user = await userAction.get();
  14. this.props.storeUser(user);
  15. } catch (err) {}
  16. }
  17. }
  18.  
  19. const state2props = (state) => ({
  20. user: state.User.user
  21. });
  22.  
  23. const dispatch2props = dispatch => ({
  24. storeUser: (user) => dispatch(userReducer.store(user)),
  25. });
  26.  
  27. export default connect(state2props, dispatch2props)(User);
Add Comment
Please, Sign In to add comment