I have the following component wrapped in a Suspense
one:
// ...
render(
<Suspense fallback={<LoadingSpinner />}>
<MyComponent {...props} />
</Suspense>
)
// ...
MyComponent
uses i18next
, which triggers a suspense which loads translations.
Eveything works, but the spinner is showed only for an instant and then it disappears because the AJAX requests i18next
is making completes.
Can I tell the Suspense
component to somehow show the spinner at least for 2 seconds? This would improve the UX visually.
It would be great to have something like this:
// ...
// minDuration - 2 seconds
render(
<Suspense fallback={<LoadingSpinner />} minDuration={2000}>
<MyComponent {...props} />
</Suspense>
)
// ...
I do not have control over the i18next
AJAX, or I think so, as it is a library.
Is it possible to achieve what I want with Suspense
?