title: Cannot destructure property `user` of 'undefined' or 'null'
body: <p>Error retrieving user information with redux.
  I want to get the user information (name, password and address of the avatar from the db) and then edit it.</p>
  
  <p>I'm using nodejs, express, react, redux and jwt.</p>
  
  <pre><code>Actions/user.js
  import axios from 'axios';
  import {setAlert} from './alert';
  
  import {GET_USER, USER_ERROR} from './types';
  
  //Get current users profile
  export const getCurrentUser = () =&gt; async dispatch =&gt; {
      try {
          const res = await axios.get('/api/users/me');
  
          dispatch({
              type: GET_USER,
              payload: res.data
          });
      } catch (err) {
          dispatch({
              type:USER_ERROR,
              payload:{msg: err.response.statusText, status: err.response.status}
          });
      }
  };
  
  Reducers/user.js
  import {GET_USER, USER_ERROR, CLEAR_USER} from '../actions/types';
  
  const initialState = {
      user: null,
      users: [],
      loading: true,
      error: {}
  }
  
  export default function(state = initialState, action) {
      const {type, payload} = action;
      switch(type){
          case GET_USER:
          return{
              ...state,
              loading:false,
              user:payload
          };
          case USER_ERROR:
              return{
              ...state,
              error:payload,
              loading: false
          };
          default:
              return state;
      }
  }
  
  Components/edituser/EditUser.js
  import React, {useState, Fragment, useEffect} from 'react';
  import PropTypes from 'prop-types';
  import {connect} from 'react-redux';
  import {getCurrentUser} from '../../actions/user';
  import {Link, withRouter} from 'react-router-dom';
  import Alert from '../layout/Alert';
  import InputSelector from '../util/InputSelector';
  
  const EditUser = ({
      user:{user,loading}, 
      getCurrentUser, 
      history}) =&gt; {
      const [formData, setFormData] = useState({
          name: '',
          email: '',
          password: ''
      });
  
      useEffect(()=&gt;{
          getCurrentUser();
      });
      return (
          &lt;Fragment&gt;
        &lt;div className="col-md-12 mb-3"&gt;
                  &lt;div className="card"&gt;
                      &lt;div className="card-body"&gt;
                          &lt;div className="row"&gt;
                              &lt;div className="col-md-3 d-flex align-items-center"&gt;
                              &lt;div className="img"&gt;
                              &lt;img className="img-fluid" src={'/uploads/noImg.jpg'} /&gt;
                          &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;div className="col-md-9"&gt;
                          &lt;form&gt;
                              &lt;div className="form-group"&gt;
                                  &lt;label&gt;&lt;i className="fas fa-user"&gt;&lt;/i&gt; Username&lt;/label&gt;
                                  &lt;input 
                                  type="text" 
                                  name="skills"
                                  className="form-control" 
                                  placeholder="Edita tu nombre de usuario"
                                  /&gt;
                              &lt;/div&gt;
                              &lt;div className="form-group"&gt;
                                  &lt;label&gt;&lt;i className="fas fa-envelope"&gt;&lt;/i&gt; Email&lt;/label&gt;
                                  &lt;input 
                                  type="text" 
                                  name="skills"
                                  className="form-control" 
                                  placeholder="Edita tu email"
                                  /&gt;
                              &lt;/div&gt;
                              &lt;div className="form-group"&gt;
                                  &lt;label&gt;&lt;i className="fas fa-key"&gt;&lt;/i&gt; Contraseña&lt;/label&gt;
                                  &lt;input 
                                  type="text" 
                                  name="skills"
                                  className="form-control" 
                                  placeholder="Edita tu nombre de contraseña"
                                  /&gt;
                              &lt;/div&gt;
                              &lt;div className="form-group" &gt;
                              &lt;label&gt;&lt;i class="fas fa-upload"&gt;&lt;/i&gt; Imagen De Perfil&lt;/label&gt;
                          &lt;InputSelector/&gt;
                          &lt;/div&gt;
                          &lt;div className="col-md-12 text-center"&gt;
                          &lt;button className="btn btn-primary btn-block"&gt;&lt;i class="fas fa-check"&gt;&lt;/i&gt; Guardar&lt;/button&gt;
                          &lt;/div&gt;
                          &lt;/form&gt; 
                          &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;/Fragment&gt;
      );
  };
  EditUser.propTypes = {
      getCurrentUser: PropTypes.func.isRequired,
      user: PropTypes.object.isRequired
  };
  
  const mapStateToProps = state =&gt; ({
          user: state.user
       });
  
  export default connect(mapStateToProps, {getCurrentUser}) 
  (withRouter(EditUser));
  </code></pre>
  
  <p><a href="https://imgur.com/xLzAu1A" rel="nofollow noreferrer">https://imgur.com/xLzAu1A</a></p>
  
  <p>The problem always happens when I write user: {user, loading}, when I put another code that I already have done it works fine, but whenever I write that the page fails.</p>