Suspense not triggered on language change
See original GitHub issueDescribe the bug
I’m using almost exact code as in the example and Suspense
is triggered only on the initial render (showing loading component). However it is not triggered when i18n.changeLanguage()
is called inside onClick
event handler. I’m using XHR backend for locale load and after button is clicked request is being sent to the server but nothing happens until everything is fetched.
I tried to set useSuspense
to false
but in such case ready
flag never gets back to undefined
of false
(on component re-render) and just re-renders component with true
value after async language change finishes.
Occurs in react-i18next version 10.6.0
Expected behaviour
When this code is executed Suspense
should trigger and display fallback
component before all messages are fetched and language is fully changed.
const handleClick = lng => {
i18n.changeLanguage(lng);
//^^^^^^^^^^^^^^^^^^^^^^^^
//This returns unhandled Promise
};
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (7 by maintainers)
ok gone the additional event way…
can you try with:
If you encounter any issues with it - let me know.