title: React keycloak TypeError: kc.updateToken(...).success is not a function
body: <p>I was on keycloak implementation.</p>
  
  <p>This is my keycloak init config:</p>
  
  <pre><code>const token = localStorage.getItem('kc_token');
  const refreshToken = localStorage.getItem('kc_refreshToken');
  
  export const keycloakInitConfig = {
    onLoad: 'login-required',
    promiseType: 'native',
    token,
    refreshToken,
  };
  </code></pre>
  
  <p>And sometimes I got this error</p>
  
  <blockquote>
    <p>TypeError: kc.updateToken(...).success is not a function</p>
  </blockquote>
  
  <p>if anybody can help me, very thanks.</p>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <pre><code>                        kc.updateToken(-1).success(function() {
                              kc.onAuthSuccess &amp;&amp; kc.onAuthSuccess();
                              initPromise.setSuccess();
                          }).error(function() {
                              kc.onAuthError &amp;&amp; kc.onAuthError();
                              if (initOptions.onLoad) {
                                  onLoad();
                              } else {
                                  initPromise.setError();
                              }
                          });
  </code></pre>
  
  <p>I have this in <code>node_modules</code> and my <code>keycloak-js</code> version is <code>6.0.0</code>.</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <pre><code>export const keycloakInitConfig = {
    onLoad: 'login-required',
    promiseType: 'native',
    token,
    refreshToken,
  };
  
  export const onKeycloakEvent = (store) =&gt; (event, error) =&gt; {
    console.log('event?????', event);
    if (event === 'onAuthSuccess') {
      keycloak.loadUserProfile()
        .then((userInfo) =&gt; {
          store.dispatch({
            type: actionTypes.SET_USER_INFO,
            payload: { user: userInfo },
          });
        })
        .catch((err) =&gt; {
          console.log('loadUserProfile: ', err);
  
          localStorage.removeItem('kc_token');
          localStorage.removeItem('kc_idToken');
          localStorage.removeItem('kc_refreshToken');
  
          store.dispatch({
            type: actionTypes.LOG_OUT,
          });
  
          keycloak.logout();
        });
    } else if (error) {
      console.log('onKeycloakEvent', event, error);
    }
  };
  
  export const onKeycloakTokens = (tokens) =&gt; {
    localStorage.setItem('kc_token', tokens.token);
    localStorage.setItem('kc_idToken', tokens.idToken);
    localStorage.setItem('kc_refreshToken', tokens.refreshToken);
  };
  </code></pre>
  
  <p>And KeycloakProvider</p>
  
  <pre><code>ReactDOM.render(
    &lt;KeycloakProvider
      keycloak={keycloak}
      initConfig={keycloakInitConfig}
      onEvent={onKeycloakEvent(store)}
      onTokens={onKeycloakTokens}
    &gt;
      ...
    &lt;/KeycloakProvider&gt;,
    document.getElementById('root'),
  );
  </code></pre>