-
-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Version
5.24.3
Describe the bug
Hi @ivanhofer, first of all thanks for the awesome lib.
I found the issue with setLocale with react - it can't be used as dependency in useEffect for example, because it causes:
Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
the code:
const { setLocale } = useI18nContext();
useEffect(() => {
setLocale('de');
return () => setLocale('en');
}, [setLocale]);Ofc I can not provide setLocale as dependency, but I think this is a bug, and setLocale must be stable as setState.
Reproduction
git clone https://github.com/vchirikov/typesafe-i18n-issue-repro
cd typesafe-i18n-issue-repro
npm i && npm run start
Logs
No response
Config
No response
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working