Closed d3vild06 closed 5 years ago
Cleaned up most of the remaining items! Let me know if you have any questions or concerns. Otherwise, I will be setting this draft PR to ready for review
soon.
Thanks @d3vild06! Do you need help resolving the merge conflicts?
Thanks for resolving those merge conflicts @d3vild06! Can you write up a quick summary of what you did? E.g. how the three higher-order components you introduced relate to the context API.
Summary of changes
Refactored the existing routes definitions and created two new HOC components to take advantage of React's Context API.
The new components are:
AuthenticatedRoute
- this replaced theRouteWithUser
component which was used to keep track of and pass the user object around to ensure only authenticated users accessed these routes and components. With the new AuthProvider sharing the context, this new component is able to consume and access theuser
object and pass it onto the target component for a particular route.AuthProvider
- this new component is responsible for creating the context for the application and exposing it to any consuming components. In addition, it provides two new functions that are used in other components to gain access (consume) to the context. This provider component is now set at the top level of our routes and components so all of the child components can "see" the context.Today, the only context of any value that we're creating is the user object. We can certainly add more context values as we see fit in the future. Lastly, minor updates were made to existing components to take advantage of this new context API.
Overall, with this change, we now remove the need to pass the user object down to nested components who need it via props and offer a way for the application to be aware of the user's state across all components.