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

fix(component-library): fix prefetching react-aria links #2210

Merged
merged 1 commit into from
Dec 21, 2024

Conversation

cprussin
Copy link
Collaborator

I noticed link navigation performance was slower than I expected in the preview builds. As it turns out, this is due to how react-aria handles client side routing -- it circumvents the nextjs Link component which is where the next link preload functionality is handled. Currently, there's no way to tell react-aria to use the nextjs Link component, so instead this PR injects the preload functionality into the unstyled wrappers for any react-aria component that can be linked.

While working on this, I also discovered that there are issue with having dependencies on react-aria-components from both the app and the component library. The react-aria-components package uses contexts to communicate between some elements; as a result it is a singleton package (or at least, for any given set of components that need to interact with each other using react-aria-components contexts, it is necessary that those components use the same package dependency for react-aria-components).

I believe the easiest way to ensure we don't accidentally ship two separate copies of react-aria-components and have issues with contexts not being shared correctly is to only depend on react-aria-components from @pythnetwork/component-library, and to re-export react-aria-components modules from there for use in downstream apps. This way apps will only ever consume @pythnetwork/component-library, which will own the actual dependency on react-aria-components. So, this PR also restructures things a bit to remove the react-aria-components dependency from the insights hub, moves all the Unstyled components to an unsyled/ directory under the component library src, and to re-export much more of react-aria-components from there.

Copy link

vercel bot commented Dec 21, 2024

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

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2024 9:16pm
component-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2024 9:16pm
insights ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2024 9:16pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2024 9:16pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2024 9:16pm

@cprussin cprussin merged commit 68c1b81 into main Dec 21, 2024
9 checks passed
@cprussin cprussin deleted the cprussin/price-feed-chart branch December 21, 2024 21:33
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.

1 participant