import update from "immutability-helper"

const user = (state = [], action) => {
  switch (action.type) {
  case "ADD_USERS":
    return action.users
  case "UPDATE_USER":
    const { userToken, newAttributes } = action
    const index = state.findIndex(user => user.token === userToken)
    return update(state, {
      [index]: { $set: { ...state[index], ...newAttributes } }
    })
  default:
    return state
  }
}

export default user

@@ -1,46 +1,4 @@
-import update from %22immutability-helper%22%0A%0A
 cons
@@ -179,139 +179,86 @@
     
-const index = state.findIndex(user =%3E user.token === userToken)%0A    return update(state, %7B%0A      %5Bindex%5D: %7B $set: %7B ...state%5Bindex%5D
+return state.map(user =%3E %7B%0A      return (user.token === userToken) ? %7B ...user
 , ..
@@ -274,17 +274,22 @@
 butes %7D 
-%7D
+: user
 %0A    %7D)%0A

use .map with equality check rather than immutability helpers with index