AxaFrance / oidc-client

Light, Secure, Pure Javascript OIDC (Open ID Connect) Client. We provide also a REACT wrapper (compatible NextJS, etc.).
MIT License
582 stars 158 forks source link

withAuthentication HOC triggers too many rerender of wrapped component #643

Closed JLou closed 2 years ago

JLou commented 3 years ago

Issue and Steps to Reproduce

When using withAuthentication from @axa-fr/react-oidc-context-fetch, the component wrapped will rerender too many times.

In 3.1.6 with my reproduction code I get "toto 2", and in "3.1.7" I get "toto 6"

3.1.6: image

3.1.7: image

git clone https://github.com/JLou/repro-bug-react-oidc.git
cd repro-bug-react-oidc
npm i
npm start

Versions

3.1.7 & below

Screenshots

image

Expected

fetch should not change during the lifespan of the app, and should definitely not trigger a rerender of my wrapped component

Actual

it does

Additional Details

guillaume-chervet commented 2 years ago

The rerender problem is fixed in v4 by sliting hooks and by removing data duplication inside react.

guillaume-chervet commented 2 years ago

I close the issue, thank you for it. The v4 fixe it. Feel free to re-open an issue if you need it.