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

Don't allow router location change until next content has arrived in the store #1528

Open
tiberiuichim opened this issue May 27, 2020 · 5 comments
Assignees

Comments

@tiberiuichim
Copy link
Contributor

tiberiuichim commented May 27, 2020

There is a very subtle problem that is perceivable only if a page has it own specially dedicated view React component, with a design that makes it obvious and easily distinguished from other components. For example, in our case, a HomepageView that has a background color or image that's different from the rest of the website.

Now for the problem. There is the following sequence of events:

  • user clicks on router link
  • router mounts the appropriate component for that route
  • the component displays itself with the current content available in the redux store!
  • on mount, the component then triggers the getAction content.
  • on new data received, the component uses the new content from the redux store and redraws itself

If this whole cycle is anything more then 40ms, it is perceivable by the user. The volto.kitconcept.com server, which is very fast, returns a ?fullobjects getContent request in 100ms+.

In my view, this is on the same level of perceivable problem as the Flash of Unstyled Content.

@tiberiuichim
Copy link
Contributor Author

Some of the stuff we've tried included a condition in the render() of component that avoids rendering any content (or render a placeholder) until the store content matches the router path.

render() {
    if (getPathname(props.content['@id']) !== props.pathname) return <Placeholder />
}

@sneridagh
Copy link
Member

@tiberiuichim @robgietema we should talk about this today, if possible. Putting it on the sprint list as a reminder.

@tiberiuichim
Copy link
Contributor Author

See #1550

@tiberiuichim
Copy link
Contributor Author

tiberiuichim commented Aug 30, 2020

I've found this sort of problem mentioned in the after.js documentation (which is Jared Palmer's (author of Razzle) - version of next.js (an integrated solution for isomorphic React apps)). In that package the router is enhanced so that it calls static getAsyncProps functions from the components so it "prefetches" the component data.

@tiberiuichim
Copy link
Contributor Author

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

No branches or pull requests

2 participants