我将以下组件包装在一个组件中Suspense:
// ...
render(
<Suspense fallback={<LoadingSpinner />}>
<MyComponent {...props} />
</Suspense>
)
// ...
MyComponentuses i18next,这会触发加载翻译的悬念。Eveything 工作,但微调器只显示一瞬间,然后它消失,因为 AJAX 请求i18next正在完成。
我可以告诉Suspense组件以某种方式显示微调器至少 2 秒吗?这将在视觉上改善用户体验。有这样的东西会很棒:
// ...
// minDuration - 2 seconds
render(
<Suspense fallback={<LoadingSpinner />} minDuration={2000}>
<MyComponent {...props} />
</Suspense>
)
// ...
我无法控制i18nextAJAX,或者我认为可以,因为它是一个库。
是否有可能实现我想要的Suspense?