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

Use store instead of props to pass userUUID #19

Closed
wants to merge 3 commits into from

Conversation

qafui
Copy link
Collaborator

@qafui qafui commented Jun 14, 2024

Description

Cleans up the SelectCoachingSession component to use the Zustand store for grabbing userUUID instead of props.

GitHub Issue: [Resolves] #17

Changes

  • ...
  • ...
  • ...

Screenshots / Videos Showing UI Changes (if applicable)

Testing Strategy

describe how you or someone else can test and verify the changes

Concerns

describe any concerns that might be worth mentioning or discussing

@qafui qafui linked an issue Jun 14, 2024 that may be closed by this pull request
@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Jun 14, 2024
@qafui qafui requested a review from jhodapp June 14, 2024 19:41
@qafui
Copy link
Collaborator Author

qafui commented Jun 19, 2024

@jhodapp Merged in your ux tweaks. We're good to 🚀

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.

Thanks for this David, I left my latest thoughts inline. Let me know what you think.

I know you mentioned this article from Vercel on passing state via Context, but I don't think their example applies directly in this case.

useEffect(() => {
async function loadOrganizations() {
if (!userUUID) return;
const { userUUID } = useAuthStore((state) => state);
Copy link
Member

Choose a reason for hiding this comment

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

I still don't prefer to break encapsulation of the SelectionCoachingSession component by directly using useAuthStore() instead of passing it as a property one level deep. Here's a good explanation of my thought process from Perplexity.ai summarizing other sites on this.

Here's my own thought process: I think it's a logical practice to retrieve state at the page level and pass user session state like userUUID down to components because components are reusable and pages are not. But a component like this one becomes less reusable when tightly coupling the AuthStore into the innards of the component.

Copy link
Collaborator

@calebbourg calebbourg left a comment

Choose a reason for hiding this comment

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

I was able to test this successfully against Jim-Hodapp-Coaching/refactor-platform-rs#50
Screen Shot 2024-07-02 at 8 54 45 AM

Awesome work!

@qafui qafui closed this Jul 6, 2024
@qafui qafui deleted the 17-refactor-to-use-store branch July 6, 2024 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves existing functionality or feature
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[Bug]: Zustand store auth-store doesn't survive a manual page refresh
3 participants