gregberge / loadable-components

The recommended Code Splitting library for React ✂️✨
https://loadable-components.com
MIT License
7.7k stars 381 forks source link

Can't get `fallback` to display component #960

Closed ValentinGurkov closed 1 year ago

ValentinGurkov commented 1 year ago

Hi everyone,

Am I not using this as inspected? I'm trying to display a placeholder component while the one I need is loading:

const ProductSlider = loadable(() => import('../../components/product-slider'), {
    fallback: <ProductSliderSkeleton />
})

But the fallback component is never displayed. I just wait a bit and my real component appears.

I'd appreciate any tips on getting this to work. I'd like to have a placeholder component in order to eliminate layout shift.

theKashey commented 1 year ago

Everything seems right. Are you sure ProductSliderSkeleton is not displayed? Could it be just invisible for any reason?

sk-roofr commented 1 year ago

Mine works fine..

ValentinGurkov commented 1 year ago

Hi @theKashey , @sk-roofr ,

I apologize for bringing you into this. It was a rookie mistake. Everything is there, things were just loading too fast, so it was hard to notice.

Thanks for trying to help.