Skip to content

Fix render loops due to bind#312

Merged
brionmario merged 2 commits intoasgardeo:mainfrom
brionmario:refactor-thunder-flows
Jan 10, 2026
Merged

Fix render loops due to bind#312
brionmario merged 2 commits intoasgardeo:mainfrom
brionmario:refactor-thunder-flows

Conversation

@brionmario
Copy link
Member

Purpose

This pull request refactors the way Asgardeo authentication and session methods are provided to consumers of the AsgardeoProvider context in the React package. Instead of directly exposing bound methods from the asgardeo instance, the provider now wraps these methods with useCallback hooks, improving consistency and potentially optimizing re-renders for components consuming the context.

The most important changes are:

Refactoring Asgardeo methods to use useCallback:

  • Wrapped key Asgardeo methods (getDecodedIdToken, getAccessToken, request, requestAll, exchangeToken, signOut, signUp, clearSession, and reInitialize) with useCallback hooks to memoize them and ensure stable references across renders.

Updating context value to use memoized methods:

  • Updated the value provided by the context to use the new memoized methods instead of directly binding methods from the asgardeo instance. This change applies to both top-level and nested (http) properties in the context value.

Synchronizing memoization dependencies:

  • Updated the dependency array for the useMemo hook that provides the context value to include the new memoized methods, ensuring the context value only changes when one of these methods or other dependencies change.

Related Issues

  • N/A

Related PRs

  • N/A

Checklist

  • Followed the CONTRIBUTING guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Unit tests provided. (Add links if there are any)

Security checks

@asgardeo-github-bot
Copy link

🦋 Changeset detected

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

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

@brionmario brionmario merged commit 1678a65 into asgardeo:main Jan 10, 2026
3 of 6 checks passed
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