Conversation
3c41b9a to
373dcfd
Compare
075e9a3 to
1aae6c6
Compare
1c0f4ec to
51ee7c3
Compare
0a3e6d5 to
15fd71a
Compare
6bb978e to
b35c0ed
Compare
47834ff to
7a40781
Compare
8da1f32 to
611fd2b
Compare
|
any idea if you could publish this as a separate alpha? |
|
@mfolnovic I'm getting close to releasing v2, at which point I can get this rebased (or at this point it might actually be easier to just copy things into a new PR) and push out a build. I haven't been paying much attention to React's Suspense development; are they getting closer to releasing suspense for data or is it still only lazy loading? |
|
@pshrmn cool, tnx for info - this PR is closest to real support for Suspense (data fetching) in router from what I tried (and I tried react router, reach router, navi). :)
As far as I know, they aren't any news regarding suspense for data fetching. [1] https://reactjs.org/blog/2018/11/27/react-16-roadmap.html |
This is a work in progress to determine the API that should be used with React suspense
Prepping Curi to be ready for React Suspense. With Suspense, a navigation cannot be completed until after it has rendered.
When a router is created with the
suspend: trueoption, the emittednavigationobject will have afinish()function attached to it. The actual navigation (updating of the history) will not happen until that function is called.There are two changes that need to be done in React.
suspendboolean prop to the<CuriProvider>. Whensuspendistrue, the provider will use deferred updates (not yet implemented because the API doesn't exist!) to update the state with the newresponse/navigation.<FinishNavigation>inside of a<React.Placeholder>. The<FinishNavigation>component will callnavigation.finish()for you once it mounts (or updates). By placing it inside of a<React.Placeholder>, we ensure that thecomponentDidMount()/componentDidUpdate()triggers are not called until any suspense code has loaded.The placeholder's fallback component also needs to be wrapped in a
<FinishNavigation>because when the fallback is displayed, the app is essentially rendering a spinner for the next page.The API here is a little verbose, but a component that combines
<React.Placeholder>and<FinishNavigation>should help.