searchReducer.js 410 B

1234567891011121314151617181920
  1. export const searchReducer = (state = {}, { type, searchUser}) => {
  2. const types = {
  3. 'SEARCH': () => {
  4. return {
  5. ...state,
  6. searchUser,
  7. }
  8. },
  9. 'CLEAR_SEARCH': () => {
  10. return {
  11. searchUser: {},
  12. }
  13. },
  14. }
  15. if (type in types) {
  16. return types[type]()
  17. }
  18. return state
  19. }