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

Hook optimization/bug fix #223

Merged
merged 2 commits into from
Oct 4, 2024
Merged

Hook optimization/bug fix #223

merged 2 commits into from
Oct 4, 2024

Conversation

BurntVal
Copy link
Contributor

@BurntVal BurntVal commented Oct 3, 2024

Description:

Aims to fix performance issues where calling useAbstraxionAccount in several components resulted in long delays and app freezes.

Changes Made:

  • Moved abstraxion-core calls to the top-level context provider to centralize authentication state management and reduce the frequency of calls to authenticate(). This change ensures that the authentication state is determined once and shared across components, minimizing repeated calculations and updates/re-renders
  • This change led to a cleaner implementation of the useAbstraxionAccount hook, as it now relies on a more stable context, reducing unnecessary complexity and improving readability.
  • Wrapped the persistAuthenticateState function in useCallback to stabilize the function reference and prevent unnecessary re-executions during re-renders
  • Refactored the useEffect hooks and dependencies to ensure optimize performance

Results:

Performance has dramatically improved on hard reloads. The app can now handle n calls to the useAbstraxionAccount hook without experiencing any performance issues.

Important Note:

There may still be a slight delay during hard reloads due to the initial configuration and setup of the underlying Abstraxion authentication system on mount. It is recommended to disable actions and buttons based on the isConnected boolean returned from the useAbstraxionAccount hook to enhance user experience during this period.

Copy link

changeset-bot bot commented Oct 3, 2024

🦋 Changeset detected

Latest commit: d368881

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@burnt-labs/abstraxion Minor
demo-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Oct 3, 2024

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

Name Status Preview Comments Updated (UTC)
xion-js-demo-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2024 4:07pm

Copy link
Contributor

@justinbarry justinbarry left a comment

Choose a reason for hiding this comment

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

LGTM

@justinbarry justinbarry merged commit 387c49c into main Oct 4, 2024
3 checks passed
@justinbarry justinbarry deleted the chore/hook-optimization branch October 4, 2024 19:24
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.

3 participants