您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

userReducer.js 501B

12345678910111213141516171819202122232425262728293031
  1. import createReducer from '../../utils/createReducer';
  2. import {
  3. SET_USER,
  4. SET_USER_ERROR,
  5. } from '../../actions/user/userActionConstants';
  6. const initialState = {
  7. user: {},
  8. };
  9. export default createReducer(
  10. {
  11. [SET_USER]: setUser,
  12. [SET_USER_ERROR]: setUserError,
  13. },
  14. initialState,
  15. );
  16. function setUser(state, action) {
  17. return {
  18. ...state,
  19. user: action.payload,
  20. };
  21. }
  22. function setUserError(state, action) {
  23. return {
  24. ...state,
  25. errorMessage: action.payload,
  26. };
  27. }