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

[examples] Add Remix example #29952

Merged
merged 10 commits into from
Dec 2, 2021
Merged

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Nov 29, 2021

This PR adds example that uses Remix and TypeScript.

Fixes #29877

Same as https://github.com/mnajdova/remix-with-mui-typescript - the commits there can be reviewed, it was faster for testing in an isolated repository.

@mui-pr-bot
Copy link

mui-pr-bot commented Nov 29, 2021

No bundle size changes

Generated by 🚫 dangerJS against a92f79a

@mnajdova mnajdova mentioned this pull request Nov 30, 2021
2 tasks
@mnajdova mnajdova marked this pull request as ready for review November 30, 2021 12:49
@mnajdova mnajdova requested a review from a team November 30, 2021 12:50
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@mnajdova
Copy link
Member Author

Should we add it in https://mui.com/getting-started/example-projects/#official-examples?

Yes, I will add it. I focused on making everything work in this first iteration.

@mnajdova mnajdova requested a review from a team December 1, 2021 08:56
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

@oliviertassinari oliviertassinari requested a review from a team December 1, 2021 11:44
@mnajdova
Copy link
Member Author

mnajdova commented Dec 1, 2021

Are we loading the default font? I couldn't find something equivalent to

Good catch! I removed it when trying to scaffold everything from start. Added it back

@mnajdova mnajdova added docs Improvements or additions to the documentation examples Relating to /examples labels Dec 1, 2021
Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍 cloned and tested!

@mnajdova mnajdova merged commit ff5459c into mui:master Dec 2, 2021
@krnbr
Copy link

krnbr commented Dec 2, 2021

is there an example which supports SSR for MUI using REMIX + Express setup?

const emotionChunks = extractCriticalToChunks(html);

// Re-render including the extracted css.
const markup = renderToString(
Copy link
Member

@oliviertassinari oliviertassinari Dec 5, 2021

Choose a reason for hiding this comment

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

I have just realized that we render twice. In https://remix.run/docs/en/v1/guides/styling, it says:

It's unlikely this will effect performance in a significant way, React is pretty fast.

I don't buy it, not for one second. React is slow on the server side. At least, it's my personal experience at Onepixel relative to other templating languages, and indexing about 10m pages with Next.js on Google. Most of the time spent to get the first byte was on rendering the React tree (react apollo was half of this time). Looking back then, I can't imagine that it would have flied to render twice.

Could we look into the feasibility to render only once? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding it to my Todo list

Choose a reason for hiding this comment

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

@mnajdova I am wondering if this can be extended to render head+body in the first pass and only head in the second: https://gist.github.com/alexkuz/d91c9ce1380f4b528ebf262ad0e4f959

that would be so far the best way of using css-in-js with remix - until it gets better support for build time css-in-js.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @jurokapsiar :) That's a good idea. I plan to look into this next week when there is not much activity on the repo. I will open a PR with my findings.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had some time today, have created #30366

I am basically inserting the style tags after an insertion point meta element that is added by the root.tsx. As far as I could test it works, but I may be missing something. It feels a bit hacky to parse the HTML string, but I don't have a better idea.

@yehudamakarov
Copy link

yehudamakarov commented Jan 24, 2022

where can I find this example in documentation? (assuming it is up somewhere already?)

@yehudamakarov
Copy link

got it sorry: https://mui.com/getting-started/example-projects/#heading-official-examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation examples Relating to /examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[examples] SSR example for Remix
8 participants