Skip to content

React Suspense fallback should not be mandatory  #19715

@stock-dd

Description

@stock-dd

In my current case I want to lazy-load components through React Router to decrease my bundle size on initial page load.

React Suspense requires a fallback prop, but I don't want it.
I render html from the server for better UX (matching the client component), and providing a loader placeholder when lazy-loading components on react router causes a flicker.
Currently I implement my own loader from within a React component, and this is the way I want it (I have a custom feed loader that is isolated in a widget, and I don't want a loader for a full page component). Not showing a loader provides much better user experience.

I don't know how to fix this with the current api, so I'm left to abandon lazy-loading components because the current UX is really a no-no.
Please advise on the motivation behind making the fallback prop mandatory, and whether you could consider abandoning that imposing idea, so I could once again use the React Suspense api to improve my initial page load speed.

You can see its effect here: https://stock-dd.herokuapp.com/home/topics/1
(Takes some time to load, free service that needs to be woken up after inactivity).

If there is a workable alternative, please do share.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions