Ability to create likes in a social media application react native

Viewed 22

https://www.veed.io/view/c11b1ceb-c344-4acf-b78e-84dc2a5f864a?sharingWidget=true

Hello, I am developing a social media application with react native and I bring all my items with flashlist, but when I like any post, I bring all the data again with the function I applied, so a problem like the video arises, can you suggest me an alternative solution for this?

This photo is all codes on the relevant page

case SetupType.LIKE_POST_SUCCESS:
      return {
        ...state,
        isLoading: false,
        error: '',
        success: '',
        All: {
          ...state?.All,
          posts: state.All?.posts?.map((post) =>
            post.uuid == action.payload.uuid
              ? {
                  ...post,
                  likes: action.payload.likes,
                  likeCount: action.payload.likeCount,
                }
              : post,
          ),
        },

        statusCode: action.statusCode,
      };
 case SetupType.UN_LIKE_POST_SUCCESS:
      return {
        ...state,
        isLoading: false,
        error: '',
        success: '',
        All: {
          ...state?.All,
          posts: state.All?.posts?.map((post) =>
            post.uuid == action.payload.uuid
              ? {
                  ...post,
                  likes: action.payload.likes,
                  likeCount: action.payload.likeCount,
                }
              : post,
          ),
        },

        statusCode: action.statusCode,
      };

the operations applied in the redux part of these

0 Answers
Related