T
TanStack15mo ago
exotic-emerald

Global error handling & Localization

Hi there! I have a question related to global error handling and localization. Since the QueryClient is created "outside" of react for stability (currently I'm using useState to persist it on potential re-renders), my normal approach of using my useTranslations hook for translations is not viable without re-creating the QueryClient. Would you advice me to re-create the QueryClient in this case when the locale changes, or do you have other suggestions of how I can implement this?
2 Replies
exotic-emerald
exotic-emeraldOP15mo ago
Would you advice me to re-create the QueryClient in this case when the local changes, or do you have other suggestions of how I can implement this?
Maybe since I'm using signals for global state managenement, I can just pass my global locale to the queryCache and mutationCache onError method. I'm currently utlizing the use-intl package's core library, to then create a translator if I don't already have one in a translatorCache . This way I don't need to re-create the QueryClient whenever the locale changes, and I can still use my Localization Management Platform (Crowdin) as the source of truth for all my translations. I'm afraid I might be doing something wrong, and would be very happy if someone would take a look at my current implementation:
No description
exotic-emerald
exotic-emeraldOP15mo ago
No description

Did you find this page helpful?