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

Add a loading indicator between <Link /> navigations #238

Closed
arunoda opened this issue Nov 10, 2016 · 6 comments
Closed

Add a loading indicator between <Link /> navigations #238

arunoda opened this issue Nov 10, 2016 · 6 comments
Assignees

Comments

@arunoda
Copy link
Contributor

arunoda commented Nov 10, 2016

When we click on a link it might take a time to load. I just peek through the code and it seems to do two async ops mainly:

  • Fetch the code
  • Fetch data

So, we need to show a loading indicator between that time.
This is my suggestion.

import React from 'react';
import Ready from 'next/ready';
import Header from '../components/Header';

const Loading = () => (<p>Loading...</p>);

export default () => (
  <div>
    /* Render all links */
    <Header onLoading={Loading}/>
    <Ready>
      <p>Hello Home Page</p>
    </Ready>
  </div>
);

If there's a link navigation request, Ready component will show the Loading component.

What do you guys think?

EDIT 2

I'm working on a new PR with just using <Link />: #250

EDIT 1

Here's the solution for this issue: #242

@sedubois
Copy link
Contributor

It is indeed annoying that nothing is visible for over a second and sometimes even longer (in my case) when clicking a link. I believe zeit.co doesn't have that issue because they preload pages with a ServiceWorker (see #24 to add it to next.js), but for us poor mortals and our users, a visual feedback would be great.

@arunoda
Copy link
Contributor Author

arunoda commented Nov 10, 2016

I hope zeit also have this. I think service workers might improve the situation but not fix it.

Anyway, I am totally blind about the service worker usage.

@tdurand
Copy link

tdurand commented Dec 11, 2016

Is there a good workaround for that in the meantime prefetch is implemented ? i just started to implement a new app with next.js and i have 1-3s wait time without any loading indicator when first loading the app different pages.

PS: just saw this PR ;-) : #238

@arunoda
Copy link
Contributor Author

arunoda commented Dec 11, 2016

@tdurand current implementation is based on Link and it's not going to work on few cases. So, we'll add a singleton Router with hooks to identify the loading event.

Hopefully, we could do it soon.

@tdurand
Copy link

tdurand commented Dec 11, 2016

Thanks, i saw the PR for service workers and very much looking forward to this one as well, for now my app is quite unusable in its current state, i'm gonna try to hack something in the meantime to get it more responsive

@arunoda
Copy link
Contributor Author

arunoda commented Dec 16, 2016

Just like #242 we need to provide a API from the singleton Router. It also has API for .go() and etc.

@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants