Hey, great post!
Question about changing data in this kind of structure like adding/deleting children of a parent:
If I want to add a new comment , the comments reducer will add the comment object and the new comment ID to the relevant sections on the comments state, but what about the post state?
Something has to update the comments array in the relevant post state with the new comment ID.
if for example I render a table of posts with comments id's column, the new comment wont show.
Should I access the comments state and for each post row map to see which comments have this post id as parent
Or
Should I just add the comment ID to the comments array in the post state on creation so I won't even need to access the comments state when rendering the posts table?
how would you structure it?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey, great post!
Question about changing data in this kind of structure like adding/deleting children of a parent:
If I want to add a new comment , the comments reducer will add the comment object and the new comment ID to the relevant sections on the comments state, but what about the post state?
Something has to update the comments array in the relevant post state with the new comment ID.
if for example I render a table of posts with comments id's column, the new comment wont show.
Should I access the comments state and for each post row map to see which comments have this post id as parent
Or
Should I just add the comment ID to the comments array in the post state on creation so I won't even need to access the comments state when rendering the posts table?
how would you structure it?