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

Consider memoizing Auth0context functions #131

Closed
zdila opened this issue Oct 15, 2020 · 1 comment · Fixed by #150
Closed

Consider memoizing Auth0context functions #131

zdila opened this issue Oct 15, 2020 · 1 comment · Fixed by #150
Labels
enhancement New feature or request

Comments

@zdila
Copy link

zdila commented Oct 15, 2020

Currently functions references of Auth0Context.Provider are changed everytime when <Auth0Provider> renders. In that case it makes useAuth0() to return different function references and then, if they are later used in dependency arrays for other hooks (eg. useEffect), they cause them to reevaluate.

From what I see it should be safe to exclude those functions from dependencies of other hooks, but react-hooks eslint rules will still complain.

Introducing useCallback for all functions of the context value in auth0-provider.tsx should fix this.

@adamjmcgrath
Copy link
Contributor

Het @zdila - thanks for your suggestion

I'll add something to our backlog to investigate this

@adamjmcgrath adamjmcgrath added the enhancement New feature or request label Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants