Implement user data state handling
Closed this issue · 0 comments
kymckay commented
This could be considered as a subtask of #163 or #162 (or even any of the other user login tasks as they all depend on this). However, I think it makes sense to track this separately and not tie it in to another PR.
My current thinking is something like:
- Use a React context to avoid prop drilling, since logged in user data can be considered as a somewhat "global" state that may need to be accessed by varying components
- Use a React reducer to separate state management logic from any rendering logic. This is also more extensible with new management logic in case we need that in future (e.g. editing username, log in, log out can apply different management logic).
- I believe
localStorage
will need to be used to persist data between sessions. As I understand it, theLink
components from Next.js allow context to persist through page links and such, but this wouldn't apply to new tabs or leaving the site then coming back (in which case we don't want to send off another request for the users data unnecessarily).- Following sync meeting this week this probably isn't relevant for now