Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

17 fix auth store refresh page bug #18

Merged
merged 13 commits into from
Jun 14, 2024
Merged

17 fix auth store refresh page bug #18

merged 13 commits into from
Jun 14, 2024

Conversation

qafui
Copy link
Collaborator

@qafui qafui commented Jun 10, 2024

Description

Updates the useEffect function to fix the infinite loop occurring on page refresh.

GitHub Issue: [Fixes] #17

Changes

  • Added userUUID to the dependency array of useEffect. This ensures the effect only runs when userUUID changes.
  • Added a check in loadOrganizations to prevent fetching if userUUID is not available. This avoids unnecessary calls on initial render.
  • Includes the changes by Jim from Select Current & Default Organization and Coaching Relationship #14 making that PR no longer necessary.

Screenshots / Videos Showing UI Changes (if applicable)

Testing Strategy

  • Login with valid credentials
  • Refresh the dashboard
  • Confirm infinite loop is absent by checking the console for errors

Concerns

describe any concerns that might be worth mentioning or discussing

Copy link
Collaborator Author

qafui commented Jun 10, 2024

@jim: decided to separate refactoring to include SWR & simplification of state management from the bug. IIt was less about Zustand loosing a stored value on refresh and more about passing the userUUID as a prop (rather than using state) AND leaving the dependency array empty.

@qafui qafui requested a review from jhodapp June 10, 2024 02:18
@qafui qafui self-assigned this Jun 10, 2024
@jhodapp jhodapp added the bug fix Fixes a specific Issue label Jun 10, 2024
@jhodapp jhodapp changed the title 17 store refresh bug 17 fix auth store page refresh bug Jun 10, 2024
@jhodapp jhodapp changed the title 17 fix auth store page refresh bug 17 fix auth store refresh page bug Jun 10, 2024
Copy link
Member

@jhodapp jhodapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, a nice simple fix. Thanks very much David - I learned something from this!

@qafui qafui merged commit 6cc5339 into main Jun 14, 2024
1 check passed
@qafui qafui deleted the 17-store-refresh-bug branch June 14, 2024 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix Fixes a specific Issue
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants