Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Stuck on LoadingComponent #191

Open
simecek-m opened this issue Jun 1, 2022 · 1 comment
Open

Stuck on LoadingComponent #191

simecek-m opened this issue Jun 1, 2022 · 1 comment

Comments

@simecek-m
Copy link

Describe the bug
I'm stuck on LoadingComponent even though Keycloak init function already failed.

To Reproduce
Steps to reproduce the behavior:

  1. set LoadingComponent to KeycloakProvider
<ReactKeycloakProvider
  authClient={authClient}
  onEvent={onEvent}
  LoadingComponent={<div>loading</div>}
>
  1. shutdown your Keycloak server
  2. wait untill initialization fail
  3. you are stuck on LoadingComponent

Expected behavior
I think LoadingComponent should be visible only when keycloak instance is not initialized AND is still loading. I have my own logic (catching "onInitError" event and redirect to Error Page showing keycloak server is unreachable) and I'm unable to do that with LoadingComponent set on, because children component is never shown.

render() {
const { children, authClient, LoadingComponent } = this.props
const { initialized, isLoading } = this.state
if (!!LoadingComponent && (!initialized || isLoading)) {
return LoadingComponent
}
return (
<AuthContext.Provider value={{ initialized, authClient }}>
{children}
</AuthContext.Provider>
)
}

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser Chrome
  • Version 102.0.5005.63

Additional context
Simple fix would be use && instead of || in render function

if (!!LoadingComponent && (!initialized || isLoading)) {

but I'm not sure if this change not gonna break any other use cases.

@smajl
Copy link

smajl commented Jul 30, 2022

This started happening to me after migrating from Vite 2 to Vite 3. 🤷

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants