When navigating to an expanded post, the app crashes. This was because we were trying to find the post to pass into our post edit modal using a .find() in our posts state in the post store. On the expanded post page, this state gets overridden to hold the expanded post replies rather than the previous post list that contained the post the user clicked on; hence, the find() operation would return undefined because that post id was no longer present in the array
Solution
To address this, we shouldn't be looking for the post in the store; rather, we should just pass it down as a prop to the post menu and edit post modal directly
Changes Made
Passed the post object down as a prop to our PostMenu and EditPostModal respectively
Related Issues
Resolves #129
Summary
Context
When navigating to an expanded post, the app crashes. This was because we were trying to find the post to pass into our post edit modal using a
.find()
in ourposts
state in the post store. On the expanded post page, this state gets overridden to hold the expanded post replies rather than the previous post list that contained the post the user clicked on; hence, thefind()
operation would returnundefined
because that post id was no longer present in the arraySolution
To address this, we shouldn't be looking for the post in the store; rather, we should just pass it down as a prop to the post menu and edit post modal directly
Changes Made
Passed the post object down as a prop to our
PostMenu
andEditPostModal
respectivelyScreenshots
No additional screenshots
Testing Instructions
No additional testing instructions
Special Notes for Your Reviewer(s)
No additional notes