@hidjou
Comment count doesn't update in Scream component, only updates in ScreamDialog if you don't refresh the page. This is because in our state we only update commentCount in scream (accessed by ScreamDialog and not also screams (accessed by Scream).
This can be fixed in dataReducer.js by replacing the code for case SUBMIT_COMMENT: with the following:
case SUBMIT_COMMENT:
let commentedOnIndex = state.screams.findIndex(
scream => scream.screamId === action.payload.screamId
);
return {
...state,
scream: {
...state.scream,
comments: [action.payload, ...state.scream.comments],
commentCount: state.scream.commentCount + 1
},
screams: state.screams.map((scream, screamsArrIndex) =>
screamsArrIndex === commentedOnIndex
? { ...scream, commentCount: scream.commentCount + 1 }
: scream
)
};
@hidjou
Comment count doesn't update in
Screamcomponent, only updates inScreamDialogif you don't refresh the page. This is because in our state we only updatecommentCountinscream(accessed byScreamDialogand not alsoscreams(accessed byScream).This can be fixed in
dataReducer.jsby replacing the code forcase SUBMIT_COMMENT:with the following: