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

Suspense! #175

Closed
jaredpalmer opened this issue Sep 11, 2018 · 18 comments
Closed

Suspense! #175

jaredpalmer opened this issue Sep 11, 2018 · 18 comments
Labels

Comments

@jaredpalmer
Copy link
Owner

Opening up discussion for what Suspense-based API will look like.

@krazyjakee
Copy link

krazyjakee commented Oct 5, 2018

@jaredpalmer at a high level, how do you envisage this affecting afterjs? What could be the benefits or problems?

Here is an article on suspense and SSR: https://blogg.svt.se/svti/react-suspense-server-rendering/

@jaredpalmer
Copy link
Owner Author

single pass rendering.

@jaredpalmer
Copy link
Owner Author

no need for after.js lol

@jaredpalmer
Copy link
Owner Author

but seriously, there will still need to be some way to hydrate even with streaming. so after.js would handle that if React pushes some of that to user land. it's hard to say.

@stale
Copy link

stale bot commented Dec 4, 2018

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

@stale stale bot added the stale label Dec 4, 2018
@krazyjakee
Copy link

krazyjakee commented Dec 9, 2018

"fizz" updates have been made to react enabling enable a better path for sssr facebook/react#14144

@renatorroliveira
Copy link

Man, so many things happening, hard to follow hahaha

So, I am just researching a better way to migrate an application on React 16 + React Router 4 + Redux Sagas to a SSR solution. I was almost decided to go with After since Next.js is "too opinionated" for my taste and Electrode seems "too complicated" (I think of it like a war machine for my simples SSR for SEO needs... maybe I am mistaken, but the bootstrapped app seems already too complicated).

Should I wait or try using alpha versions of React 17? I am divided right know between After and try React 17 by hand. @jaredpalmer It would be too hard to migrate an After based SSR app to the new approach introduced by React 17?

@krazyjakee
Copy link

@renatorroliveira check my comment here #133 (comment)

As I see it essentially removes the need for getInitialProps which both next and Afterjs use.

I'm very sure it will be simple to move logic out of getInitialProps and into a function called by suspense. Both return props so I'm confident it would be simple.

@jaredpalmer
Copy link
Owner Author

It's hard to say for sure, but yes we could do what @krazyjakee described. However, the entire premise of getInitialProps would be theoretically void when SSR suspense arrives because you no longer would be forced to inject data top-down.

@krazyjakee
Copy link

krazyjakee commented Jan 22, 2019

@jaredpalmer unrelated question. In a post-getInitialProps world, where would a component receive the afterjs context to, for example, set the response status code?

Edit: Related tweet https://twitter.com/jaredpalmer/status/1090261003655409664?s=19

@stale
Copy link

stale bot commented Mar 31, 2019

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

@stale stale bot added the stale label Mar 31, 2019
@krazyjakee
Copy link

Nooooo don't you dare. Palmdawg needs this issue.

@stale stale bot removed the stale label Mar 31, 2019
@stale
Copy link

stale bot commented May 30, 2019

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

@stale stale bot added the stale label May 30, 2019
@stale
Copy link

stale bot commented Jun 6, 2019

Closed due to inactivity. Holler if this is a mistake, and we'll re-open it.

@stale stale bot closed this as completed Jun 6, 2019
@Ricki-BumbleDev
Copy link

Just found react-lightyear, which exposes a renderToStringAsync function and threw it together with fetch-suspense, which exposes a useFetch hook supporting Suspense. And it actually works! (Only thing I had to do is to tweak fetch-suspense to use isomorphic-fetch)

@krazyjakee
Copy link

@Ricki-BumbleDev got a minimal project we can look at?

@Ricki-BumbleDev
Copy link

Here you go: https://github.com/Ricki-BumbleDev/react-fetch-suspense-ssr-demo

@Ephem
Copy link

Ephem commented Aug 31, 2019

@Ricki-BumbleDev Glad you found it useful! 😄

@krazyjakee There are also a couple of examples in the repo itself, for using with Redux, Apollo (using the unofficial react-apollo-hooks) or urql.

Checking out After.js has been on my list for a while but I haven't gotten around to it. After finding this issue I skimmed the Custom/Async Rendering-part of the documentation and there should be no problem just switching out the renderToString from React to renderToStringAsync from react-lightyear instead and everything should just work!

Whether it actually makes sense to use After.js for this instead of just using Razzle directly (which I do in the examples) I couldn't say. 😄

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

No branches or pull requests

5 participants