diff --git a/packages/realm-react/src/UserProvider.tsx b/packages/realm-react/src/UserProvider.tsx index 89fee116de..908fe71f0e 100644 --- a/packages/realm-react/src/UserProvider.tsx +++ b/packages/realm-react/src/UserProvider.tsx @@ -59,7 +59,9 @@ export const UserProvider: React.FC = ({ fallback: Fallback, const [user, setUser] = useState(() => app.currentUser); const [, forceUpdate] = useReducer((x) => x + 1, 0); - // Support for a possible change in configuration + // Support for a possible change in configuration. + // Do the check here rather than in a `useEffect()` so as to not render stale state. This allows + // for the rerender to restart without also having to rerender the children using the stale state. const currentUser = app.currentUser; if (userWasUpdated(user, currentUser)) { setUser(currentUser);