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

Avoid unnecessary rerenders with canAccess hooks when there is no authProvider #10200

Merged
merged 4 commits into from
Sep 13, 2024

Conversation

djhi
Copy link
Collaborator

@djhi djhi commented Sep 12, 2024

Problem

As we use react-query for the canAccess hooks, users may see at least one rerender because it run asynchronously.

Solution

Detect there is no support for canAccess and return a fake react-query result if needed.

How To Test

The useCanAccess and useCanAccessResources have stories with and without an AuthProvider that shows the behavior.

Additional Checks

  • The PR targets master for a bugfix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)

@fzaninotto fzaninotto merged commit 50b4833 into authprovider_canaccess Sep 13, 2024
14 checks passed
@fzaninotto fzaninotto deleted the optimize-can-access-hooks branch September 13, 2024 08:51
@fzaninotto fzaninotto added this to the 5.3.0 milestone Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants