Silent signin causes rerender on component wrapped with OidcSecure
See original GitHub issueIssue and Steps to Reproduce
I have a following structure of application: App.jsx:
import React from 'react';
import { AuthenticationProvider, InMemoryWebStorage, oidcLog } from '@axa-fr/react-oidc-context';
import Routes from 'src/Routes';
import {
Authenticating,
CallbackComponent,
NotAuthenticated,
NotAuthorized,
SessionLostComponent,
} from 'src/components/Auth';
import oidcConfiguration from 'src/oidc-configuration';
function App() {
return (
<AuthenticationProvider
authenticating={Authenticating}
callbackComponentOverride={CallbackComponent}
configuration={oidcConfiguration}
isEnabled
loggerLevel={oidcLog.DEBUG}
notAuthenticated={NotAuthenticated}
notAuthorized={NotAuthorized}
sessionLostComponent={SessionLostComponent}
UserStore={InMemoryWebStorage}
>
<Routes />
</AuthenticationProvider>
);
}
export default App;
oidc-configuration.js
const oidcConfiguration = {
acr_values: 'neededAcrValues',
client_id: 'myClientId',
redirect_uri: 'https://chat-app.example.com/auth',
response_type: 'code',
post_logout_redirect_uri: 'https://chat-app.example.com',
scope: 'openid',
authority: 'https://identity-provider.example.com',
silent_redirect_uri: 'https://chat-app.example.com/silent-renew',
automaticSilentRenew: true,
loadUserInfo: true,
monitorSession: true,
};
export default oidcConfiguration;
Routes.jsx
import React from 'react';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import { OidcSecure } from '@axa-fr/react-oidc-context';
import Chat from 'src/components/Chat ';
const history = createBrowserHistory();
function Routes() {
return (
<OidcSecure>
<Router history={history}>
<Switch>
<Route component={Chat} path="/" />
</Switch>
</Router>
</OidcSecure>
);
}
export default Routes;
And after every silent renew I get my chat component rerender which is frustrating because i loose my component state.
My Chat
component have its own nested routing for selected conversation inside the chat.
Versions
“@axa-fr/react-oidc-context”: “3.1.0-alpha.0”,
Screenshots
Expected
Just silent renew - no rerender should happen.
Actual
After every silent renew I get my chat component rerender which is frustrating because i loose my component state.
Additional Details
I’ve tried to protect routing like this:
withOidcSecure(Dashboard)
import React from 'react';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import { OidcSecure } from '@axa-fr/react-oidc-context';
import Chat from 'src/components/Chat ';
const history = createBrowserHistory();
function Routes() {
return (
<OidcSecure>
<Router history={history}>
<Switch>
<Route component={withOidcSecure(Chat)} path="/" />
</Switch>
</Router>
</OidcSecure>
);
}
export default Routes;
But it caused a rerender on every nested route change
- Installed packages: “history”: “4.10.1”, “oidc-client”: “1.10.1”, “react”: “16.13.1”, “react-dom”: “16.13.1”, “react-router-dom”: “5.1.2”
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (9 by maintainers)
Top Results From Across the Web
wrapping a component in OidcSecure causes ... - GitHub
I have wrapped secure components in OidcSecure and when silent renew refreshes token then something causes the component to unmount ...
Read more >react-oidc-auth - npm
The SilentRefreshCallback component basically wraps logic from UserManager. ... callback URLs for sign-in, sign-out and silent refresh.
Read more >Unexpected token 'else' in oidc-client.min.js causing react app ...
Here's what I've got in my silent-refresh.html: ... signinSilentCallback() } catch (err) { console.log('silent sign in failed') ...
Read more >How to stop re-rendering lists in React? - Alex Sidorenko
If you don't want a component to re-render when its parent renders, wrap it with memo. After that, the component indeed will only...
Read more >How To Implement OIDC Authentication with React Context ...
We are going to apply the mechanism needed to refresh the token of the ... callback: This component is going to be used...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Glad to see that !! Not alpha could be released on monday I think.
And thank you very much to your contributions ! 🍻
I have 2 websites and aone of them have the same problem and not the other.
I will be able to check it next week.