Loading state is always true on first render

Author: StadnykYuraCreated Feb 1, 2024Updated Mar 21, 2025

Hi, i have a question about basic client side loadable function behavior for SPA, when the chunk has been already loaded and we try to render it again. So imagine.

  1. we move to our page where the lazy component should be rendered. The loader is rendered, the chunk is loaded and the component is rendered;
  2. we leave the page where the lazy component was rendered. And then go back to this page, expecting the lazy component to be rendered immidiately. But instead it renders the loader first, and only then the actual lazy component.

So i analyzed the source code, and i have found out that the 'loading' state is always true at first.

So the question is -> is it possible to somehow change this behavior by current library functionality so the component would be rendered immidiately (without loader) if the chunk was loaded before?

Source: gregberge/loadable-components