RFC/Proof of concept: Adopt Suspense and Concurrent Mode roughly following Relay's Entry Points#2922
Draft
taneliang wants to merge 20 commits into
Draft
RFC/Proof of concept: Adopt Suspense and Concurrent Mode roughly following Relay's Entry Points#2922taneliang wants to merge 20 commits into
taneliang wants to merge 20 commits into
Conversation
a15ca6d to
5a99e30
Compare
…ata in module pages
39 tasks
This file contains hidden or 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
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
PreloadingLinkandPreloadingNavLinkcomponents (which wrap React Router'sLinkandNavLinkrespectively), allowing all links in the app to automatically preload on hover.preparefunction for all entry points that are displayed in the current route.preparefunctions are simply functions that preload data, which are fed into components as apreparedprop.Concerns
preparedefinitions 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
Linkcomponent, and thevenuedata preload now happens on click instead of on hover.Known Issues
getPreparedPropsfunctions may be called multiple times when navigating between pages. Ideally we'll fix this by callinggetPreparedPropsonce and feeding its result into the component, but React Router'spreloaddoesn'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 adisposePreparedPropsfunction, which can invalidate resources when the entry point unmounts.ScrollToTopis overeager when navigating back/forwards on module pages. I suspect this is becauseModulePageContentis now remounted.Out of scope
connectto react-redux hooks