marmelab/ra-keycloak

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

Closed this issue · 6 comments

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.

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

@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.

You have to fork the repository first.

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

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

djhi commented

Not needed anymore with v2