Skip to content

Instantly share code, notes, and snippets.

@TenzenIga
Last active April 21, 2022 12:26
Show Gist options
  • Save TenzenIga/7e3e49ea8906940842bb0ba2e1d2735e to your computer and use it in GitHub Desktop.
Save TenzenIga/7e3e49ea8906940842bb0ba2e1d2735e to your computer and use it in GitHub Desktop.

Провести code review для следующей части кода, которая используется в качестве redux reducer.

export const initialState = {
    test: null,
    post: [{
        title: null,
        author: {
            email: null,
            userPic: null,
        },
    }],
}

export default function reducer(state = initialState, action) {
    const payload = action.payload
    switch(action.type) {
        case 'ADD_POST': {
           return {
                ...state,
                post: [...state.post, {
                  title: payload.title,
                  author: {
                    email: payload.author.email,
                    userPic: payload.author.userPic,
                    }
                  }]
               }
            }
     switch(action.type) {
          case 'CHANGE_TEST': {
            return {
                ...state,
                test:payload.test
              }
           }
       }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment