reactjs / reactjs/react.dev

How to keep the current page/view when lazy loading?

Open
#2,927 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

I do not know whether it is possible to instruct Suspense to use the current page/view as the fallback component until the next view is ready to be rendered.

Indeed, in order to achieve YouTube or GitHub like loading with a top linear progress bar on the current view, we need a way to instruct the Suspense component to not unmount the current view straight away or to just add an additional child component to the current view.

The documentation would benefit from adding such example, as this behaviour is now the industry norm and it greatly improves the UX. As on StackOverflow and other relevant forums no one seems to know how to do:
https://stackoverflow.com/questions/55669865/is-it-possible-to-keep-the-current-component-mounted-as-the-fallback-content-f
https://stackoverflow.com/questions/57741868/how-can-react-suspense-remain-on-the-same-page-lazyloading

However, I am not sure this is possible right now, and if not putting it on the backlog as a new feature will be useful.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Suspense behavior described in the issue and the two linked discussions to determine whether the current view can remain mounted during lazy loading. Document the supported behavior with a loading example if possible, or clarify that the requested fallback behavior is not currently available.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation, frontend
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.