I am changing the state, but subscribed components are not rendered

  arrays, javascript, react-redux, reactjs, redux

I find the index number of the element, change a value in that index in order not to break the order in the array, dispatch it as a new array but subscribed components are not rendered.

     var userPhotoIndex = userPhotos.findIndex(p => p.photoId === photoId) 
    
     if (userPhotoIndex > -1) {
        userPhotos[userPhotoIndex].likeCount -= 1;
        dispatch(getUserPhotosSuccess([...userPhotos]))
      }

Source: Ask Javascript Questions

LEAVE A COMMENT