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

feat(react-18): Add official React 18 SSR support #290

Merged
merged 4 commits into from Aug 15, 2022

Conversation

damassi
Copy link
Member

@damassi damassi commented Aug 12, 2022

Closes #289
Closes #260

All credit goes to @gurkerl83 and the work he spearheaded in #289 and the investigations in #260. Much appreciated!

This PR integrates that work and updates the examples a bit. One thing that I did do here after experimenting within the NextJS example was integrate the suspense boundary directly into <Media> so that we don't have any forced breaking changes in the API and the library behaves as it did before.

In my testing (and updated in this PR's examples), <Suspense> still works as one would expect within the children of <Media>, even though <SuspenseBoundary> is contained higher-up. I know Dan mentioned that this is a UI thing and that <Suspense> should only ever be invoked by library consumers in userland, but in this case it makes sense to keep it in the lib and things (seem) to work just fine. We should track changes to React and update accordingly.

@gurkerl83 - do you have any strong objections to this?

To test:

yarn link
yarn watch 

and then in another tab

cd examples/nextjs
yarn link @artsy/fresnel 
yarn dev

Will update tests tomorrow and cut a new release.

Gritsch Markus and others added 3 commits August 10, 2022 16:13
Leftovers: The class component lifecycle shouldComponentUpdate has to be migrated to a functional component.
Leftovers: The media component currently supports only the render prop variant. Other required components to make this approach work, such as suspense wrapper and suspender, are not integrated. A discussion has to be started if those components have to live in the user-land.
children,
}) => {
/**
* TODO: The class component lifecycle shouldComponentUpdate
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there's no clear way to check state within React.memo just going to skip this for now.

}

return (
<Suspense fallback={null}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we want to enable custom fallbacks here or it's not needed because of SSR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever we'd want to catch will be caught higher up in their code (if the user decides to show a suspense boundary); this is just to trigger the cleanup mechanism internal to the lib

@gurkerl83
Copy link

@damassi if you have time, could you please adjust the pr with the comments I made and provide a new release. Thx!

@damassi
Copy link
Member Author

damassi commented Aug 15, 2022

@gurkerl83 - which comments are you referring to? (I'm not seeing anything in this PR.)

Hoping to wrap this up today; we're in the middle of a product launch right now so keep getting pulled away and onto other tasks but should be able to get to this later.

@gurkerl83
Copy link

gurkerl83 commented Aug 15, 2022

@damassi Not sure, but I see a few of mine in pending state. They are more syntactic wise not passing renderChildren and isPending, only cassName in case of render prop variant…

@damassi
Copy link
Member Author

damassi commented Aug 15, 2022

If you can hit the 'finish review' button then i'll see your comments; i can't see them until they've been posted.

@gurkerl83
Copy link

Sry I don’t See such a Button on my end. As you are the committer I think you have to resolve. When it’s not possible simply merge, because everything is ok. I can provide something which resolves those things tomorrow.

@damassi
Copy link
Member Author

damassi commented Aug 15, 2022

but I see a few of mine in pending state

If i'm understanding correctly, it seems like you've submitted PR comments as part of a PR review, but haven't completed the review; if you open this UI you should be able to submit the review and I will be able to see your comments:

Screen Shot 2022-08-15 at 1 34 21 PM

Other than that, not too sure. Maybe try re-adding your comments and posting them as single comments, per this button?

Screen Shot 2022-08-15 at 1 35 56 PM

Forgive me if i'm misunderstanding! But i can't see your PR comments as it is, and thus can't address them.

@damassi damassi force-pushed the gurkerl83-React-18-Suspense-Integration branch from c7da912 to 8bb8b84 Compare August 15, 2022 23:09
@damassi
Copy link
Member Author

damassi commented Aug 15, 2022

PR is green and all of our existing tests pass, so going to ship this out @gurkerl83. For any other follow-up issues please comment on the PR here or in a new issue and I'll take care of it tomorrow.

Thanks again so much for your help with this 🙏 💯

@damassi damassi merged commit ee17eaa into main Aug 15, 2022
@damassi damassi deleted the gurkerl83-React-18-Suspense-Integration branch August 15, 2022 23:22
@artsyit
Copy link
Contributor

artsyit commented Aug 15, 2022

🚀 PR was released in v5.0.0 🚀

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

Successfully merging this pull request may close these issues.

Breaking change with latest React experimental builds
4 participants