Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspense with useTransition hook #4

Open
xsfunc opened this issue Aug 5, 2022 · 1 comment
Open

Suspense with useTransition hook #4

xsfunc opened this issue Aug 5, 2022 · 1 comment
Labels
question Further information is requested

Comments

@xsfunc
Copy link

xsfunc commented Aug 5, 2022

In each page I use Suspense with fallback for lazy loading.

const Page = lazy(() => import('./ui'))

export const SomePage = () => (
  <Suspense fallback={<Loading />}>
    <Page />
  </Suspense>
)
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'

export const Loading = () => {
  useEffect(() => {
    nprogress.start()
    return () => {
      nprogress.done()
    }
  }, [])

  return null
}

It works good. When I go to some page I see progressbar while page loading. But I see only progress bar. And for good UX, it is sometimes better to show the “old” UI while the new UI is being prepared.

It's now possible with startTransition. You can read more about this case here.

I read source of atomic-react-router, but my expertise was not enough to implement this feature. Maybe you know how to do it.

@sergeysova sergeysova added the question Further information is requested label Aug 5, 2022
@Kelin2025
Copy link
Collaborator

Kelin2025 commented Aug 22, 2022

Cool, thanks for the info
We probably need to think about adding it to the core, to make it available not only for react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants