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

Update example to use ref instead of state for keycloak existence check #8

Open
ttante opened this issue Feb 1, 2024 · 5 comments
Open
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@ttante
Copy link

ttante commented Feb 1, 2024

The example provided causes an infinite redirect loop, similar to the the one described here and in many other instances with keycloak and the keycloak-js module.

In the example provided the keycloak existence check on this line causes an extra render in the app, which causes keycloak to redirect infinitely.

I resolved this by creating a new ref called 'didInit' (default value of false), which i set to true alongside keycloak init. Checking for the existence of this ref instead of the 'keycloak' state-stored variable resolves the extra render, which allows keycloak to work smoothly.

If there is a preferred workaround please let me know, otherwise I advise updating the example to use a ref as I described.

@fzaninotto
Copy link
Member

Nice! Would you like to open a PR to fix the documentation?

@fzaninotto fzaninotto added bug Something isn't working documentation Improvements or additions to documentation labels Feb 2, 2024
@ttante
Copy link
Author

ttante commented Feb 2, 2024

@fzaninotto I made the changes in a branch but I don't have access to push. Not sure if it's an access thing or I just don't have my credentials correct. I don't normally have issues pushing.

@fzaninotto
Copy link
Member

You have to fork the repository first.

@MattMx
Copy link

MattMx commented Apr 15, 2024

@ttante Could you please provide a snippet containing your changes? Sadly I also encountered the infinite loop problem

@MattMx
Copy link

MattMx commented Apr 16, 2024

I believe I resolved the issue thanks to an awaiting pull request:
#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants