Estoy codificando junto con el tutorial de Redux Essentials.
Cuando ejecuto notificaciónArray.map sin usar el valor de retorno, mi estado se actualiza según las devoluciones de llamada de las funciones del mapa.
Es decir, en allNotifiicationsRead , la propiedad de read de cada notificación se establece en true en el estado de la aplicación. Y en fetchNotifications , todas las propiedades isNew de cada notificación se establecen en !read .
Esperaría que esta notificationArray.map(...) no tenga ningún efecto, ya que no estoy usando el valor de retorno, y mucho menos editando el estado con él, como notificationsAdapter.setMany(notificationArray) .
Cualquier aclaración sobre cómo funciona esto sería apreciada.
Avíseme si no incluí ningún detalle relevante sobre esta aplicación.
const notificationsSlice = createSlice({ name: 'notifications', initialState: notificationsAdapter.getInitialState(), reducers: { allNotificationsRead(state, action) { const notificationArray = Object.values(state.entities) notificationArray.map(notification => ( notification.read = true )) } }, extraReducers(builder){ builder.addCase(fetchNotifications.fulfilled, (state, action) => { notificationsAdapter.upsertMany(state, action.payload) const notificationArray = Object.values(state.entities) notificationArray.map(notification => ( notification.isNew = !notification.read )) }) } })