sanderdebr/redux-crud-tutorial

Cannot read properties of undefined (reading 'name')

Opened this issue · 0 comments

http://localhost:3001/edit-user/1

when attempting to get to the edit path for an id the element is not initialized

TypeError: Cannot read properties of undefined (reading 'name')
EditUser
src/features/users/EditUser.jsx:18
  15 | const dispatch = useDispatch();
  16 | const history = useHistory();
  17 | 
> 18 | const [name, setName] = useState(user.name);
     | ^  19 | const [email, setEmail] = useState(user.email);
  20 | const [error, setError] = useState(null);
  21 |