You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might be simpler to keep a single list of all loaded mentors in one place in your redux store, instead of having the idea of "all mentors" and "current mentor" live in different places / reducers, to avoid having the same mentor data be duplicated in two places.
You could use allMentors as your mentor storage and then MentorPanel can look for individual mentors (the way you use currentMentor, in the mentor panel) by looking in allMentors for a specific mentorId. This lookup could happen in mapStateToProps, you could even write a selector to make this easier. Then in componentDidMount, if it doesn't find it (if currentMentor has no data), then you can kick off the network request to load that individual mentor like you currently are:
I think this will work good because if the user clicks on a card from the dashboard, then that mentor's data is already loaded when MentorPanel is being created, so you don't have to make another network request and display the "loading" content to the user for a split-second. But if that mentor is not already loaded in the store because the user opened a specific mentor's url directly, it will still load that mentor from the network.
Also, having the data live in just one place instead of being duplicated in two places will lessen the chance that they get out-of-sync as they change. For example, right now if the user updates a mentor's bio, that mentor will get updated after postField succeeds in the currentMentor reducer, but I don't think the allMentors copy of that mentor's data would get updated, so the user might return to the dashboard and see stale data.
The text was updated successfully, but these errors were encountered:
It might be simpler to keep a single list of all loaded mentors in one place in your redux store, instead of having the idea of "all mentors" and "current mentor" live in different places / reducers, to avoid having the same mentor data be duplicated in two places.
You could use allMentors as your mentor storage and then MentorPanel can look for individual mentors (the way you use currentMentor, in the mentor panel) by looking in allMentors for a specific mentorId. This lookup could happen in mapStateToProps, you could even write a selector to make this easier. Then in componentDidMount, if it doesn't find it (if currentMentor has no data), then you can kick off the network request to load that individual mentor like you currently are:
mpcc-assistant/src/client/components/mentorPanel/MentorPanel.js
Line 15 in 6c0d9f5
I think this will work good because if the user clicks on a card from the dashboard, then that mentor's data is already loaded when MentorPanel is being created, so you don't have to make another network request and display the "loading" content to the user for a split-second. But if that mentor is not already loaded in the store because the user opened a specific mentor's url directly, it will still load that mentor from the network.
Also, having the data live in just one place instead of being duplicated in two places will lessen the chance that they get out-of-sync as they change. For example, right now if the user updates a mentor's bio, that mentor will get updated after postField succeeds in the currentMentor reducer, but I don't think the allMentors copy of that mentor's data would get updated, so the user might return to the dashboard and see stale data.
The text was updated successfully, but these errors were encountered: