question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useSuspense false and use of loaders when not ready do not seem to work well

See original GitHub issue

Hello all,

I am using react-i18next with useSuspense set to false. Then I grab the translations like this:

const {t, ready} = useTranslation("header-footer");
const translationsAvailable = ready;

Then in my render I have this:

if (translationsAvailable === false){
        return (
            <div className="text-center">
                <Loader height={30} weight={30} />
            </div>
        );
    }

However, when I enter the website or refresh, etc. For a fraction of a second I can see the translation keys(e.g. “header-home”, “header-about”, etc.) rather than my loader.

Based on the documentation I think I am doing everything needed. Is this a bug or is this expected?

Thank you in advance and kind regards.

  • Device: 15" Laptop
  • Browser: Firefox 69.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
onestopjscommented, Sep 11, 2019

@PsychedMagnet https://react.i18next.com/latest/usetranslation-hook#what-it-does does both

I didn’t even know it is possible, even looking at the source I still don’t understand how that is. Anyways, discard my comment in this case! 😄

Edit: now I see it, really clever trick

0reactions
jamuhlcommented, Sep 17, 2019

closing this for now…feel free to reopen with more insights

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-i18next suspense - Stack Overflow
Just be aware that choosing not to use Suspense has its implications. ... is not ready and your component render when the state...
Read more >
Suspense for Data Fetching (Experimental) - React
It's a mechanism for data fetching libraries to communicate to React that the data a component is reading is not ready yet. React...
Read more >
Using React 18's Suspense to Improve Code Quality of Web ...
Take a look at the example below, which uses the Suspense wrapper to display a typical loader until the <LazyLoadComponent> is ready.
Read more >
All You Need To Know About React Suspense - CopyCat Blog
What does React Suspense lets you do and what does it not? React Suspense Frequently Asked Questions. Why Do We Use Suspense in...
Read more >
React Suspense: Lessons Learned While Loading Data
Fortunately, the React team was smart enough to not limit these efforts ... work I've done on my side project (again, don't use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found