-
Notifications
You must be signed in to change notification settings - Fork 320
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
RFC/Proof of concept: Adopt Suspense and Concurrent Mode roughly following Relay's Entry Points #2922
Draft
taneliang
wants to merge
20
commits into
master
Choose a base branch
from
eliang/suspense
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
taneliang
force-pushed
the
eliang/suspense
branch
from
October 22, 2020 00:50
a15ca6d
to
5a99e30
Compare
…ata in module pages
39 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
TL;DR we remove react-loadable and React Router and replace them with a DIY solution with Suspense and Relay-like Entry Points (or at least my understanding of entry points). Concurrent Mode is needed for
useTransition
, but I think we can remove it if we don't like it/it causes problems/it's too unstable.This PR is very much a WIP. Only the http://localhost:8080/timetable/sem-1, http://localhost:8080/today, and all module pages work at this moment. Many things are also broken, including hot reload. What works are loading one URL (e.g. the timetable) and hovering over another to preload its code. The today page will also start loading its data on click, before the Today component renders.
Key goals
PreloadingLink
andPreloadingNavLink
components (which wrap React Router'sLink
andNavLink
respectively), allowing all links in the app to automatically preload on hover.prepare
function for all entry points that are displayed in the current route.prepare
functions are simply functions that preload data, which are fed into components as aprepared
prop.Concerns
prepare
definitions closer to their modules.Implementation
The general idea is based on https://github.com/relayjs/relay-examples/blob/master/issue-tracker. I suspect that example repo follows old-ish FB practices, but I don't think any current approach they're using will be too different from it.
GIFs
Preloading on hover:
This is similar-ish to existing behavior, but now done by the
Link
component, and thevenue
data preload now happens on click instead of on hover.Known Issues
getPreparedProps
functions may be called multiple times when navigating between pages. Ideally we'll fix this by callinggetPreparedProps
once and feeding its result into the component, but React Router'spreload
doesn't do that, and it seems impossible to match preloaded data to its component after. I think this is a reasonable limitation: entry points also have adisposePreparedProps
function, which can invalidate resources when the entry point unmounts.ScrollToTop
is overeager when navigating back/forwards on module pages. I suspect this is becauseModulePageContent
is now remounted.Out of scope
connect
to react-redux hooks