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

Move configuration to a single context #190

Merged
merged 2 commits into from
Jul 10, 2024
Merged

Move configuration to a single context #190

merged 2 commits into from
Jul 10, 2024

Conversation

jribbink
Copy link
Contributor

@jribbink jribbink commented Jul 10, 2024

closes #191

Currently, configuration (i.e. that received from FCL via WalletUtils & that derived from query parameters) is not managed as any sort of global state.

It is either passed passed through props OR (in the case of WalletUtils) requested from the client FCL instance in many places as needed.

This presents a few issues for the planned v2 expansion to FCL Discovery (which I have ran into trying to implement these changes)

  1. We quickly run into "prop drilling" where variables used by few low-level components are repeatedly passed through parent props (making it difficult to understand where state is coming from)
  2. Discovery is continuously sending FCL the "READY" state in order to receive the initialization config in different places throughout the app whenever the useFCL hook is called. Not inherently bad, but shared state would allow us to only query this once and reuse it throughout the app.
  3. Without a global context, it's difficult to create SWR hooks throughout the app which rely on this configuration (i.e. a useWallets hook, which is necessary as multiple components need access to this API call). This again necessitates prop drilling and instantiating state at a much higher level in the application than where it is used.

Copy link

vercel bot commented Jul 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fcl-discovery ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2024 10:05pm

@jribbink jribbink changed the base branch from master to v2 July 10, 2024 19:28
@jribbink jribbink marked this pull request as ready for review July 10, 2024 21:16
@jribbink jribbink requested a review from a team as a code owner July 10, 2024 21:16
Copy link
Member

@chasefleming chasefleming left a comment

Choose a reason for hiding this comment

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

Looks good. Left one comment though.

hooks/useWallets.ts Show resolved Hide resolved
hooks/useWallets.ts Show resolved Hide resolved
hooks/useWallets.ts Outdated Show resolved Hide resolved
@jribbink jribbink merged commit fcca4a0 into v2 Jul 10, 2024
3 checks passed
@jribbink jribbink deleted the jribbink/fcl-context branch July 10, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants