Silent renew not working when in Strict Mode
Episodex opened this issue · 1 comments
Episodex commented
I had a problem, similar to #361 except the PR merged then didn't fix my problem. It turned out that AuthContext
is being mounted twice when React is in Strict mode. This causes this line to run: isMountedRef.current = false;
and nothing then sets it back to true. Which effectively disables updating user info:
oidc-react/src/AuthContext.tsx
Line 138 in d6958d1
I fixed it by setting isMountedRef.current
to true
on every mount:
useEffect(() => {
isMountedRef.current = true; // <-- my change
return () => {
isMountedRef.current = false;
};
}, []);
I'm not sure if it's the right way, but it seems to solve the problem for me. Maybe it's worth adding to the repo.