-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Integration of new Server Rendering API #15277
Comments
@raymondsze It's a good question. I think that we can update the documentation: --- a/docs/src/pages/css-in-js/api/api.md
+++ b/docs/src/pages/css-in-js/api/api.md
@@ -120,6 +120,17 @@ import { ServerStyleSheets } from '@material-ui/styles';
const sheets = new ServerStyleSheets();
+### instance args
+
+The `ServerStyleSheets` instantiation call accepts an `options` object as a first argument.
+The options are spread as props to the [`StylesProvider`](#stylesprovider) component.
+
+```js
+const sheets = new ServerStyleSheets({
+ disableGeneration: true,
+});
+```
+
### `sheets.collect(node) => void`
The method wraps your node in a provider element. Do you want to give it a shot? 10 issues, 0 pull request, it would be awesome to contribute back :). For Apollo, you can do: <StylesProvider disableGeneration>{/* My React Tree */}</StylesProvider> For the theme color, most people keep it static, now, nothing prevents you from chaning the value. I don't understand. |
I made repo that uses the new API, including disableGeneration when using Apollo's getDataFromTree: https://github.com/heysailor/material-ui-nextjs |
I have a question in mind. If i do I'm thinking of sticking to old api and directly use StylesProvider instead of ServerStylesSheet. Would like to ask if it would be deprecared or not? or ServerStylesSheet is just a tiny helper for simplification. |
It's safe to nest two StylesProvider before rendering the UI components. |
The StylesProvider won't be deprecated. The sheet manager and collector are no longer documentation. These two objets are now considered internals. As long as it's documented, you are good. |
* update the documentation of ServerStyleSheets api #15277 * small tweaks * cleanup * warn about the correct call order * Seb review
I was using
Material UI
withApollo
andNext.js
.Previously I use the
StylesProvider
for the rendering in App Component. I passdisableGeneration
astrue
toStyleProvider
to perform Apollo Server-side rendering.I found that the new guide has been changed to
ServerStyleSheet
.StylesProvider
has been changed tosheets.collect
.I think it is not great to new a
ServerStyleSheet
and passsheets.collect
to App Component render function. I see the latest example use theServerStyleSheet
in thedocument.tsx
instead ofapp.tsx
.If I do so, how could I pass
disableGeneration
during Apollo Server-side rendering? Do I need two ServerStyleSheet instance? If not, how to do that?And could the nextjs example be enhanced that we could dynamically change the theme color on client-side? I think it is a very common use-case, but its a bit tricky as we have to share the theme color in a memoized context.
The text was updated successfully, but these errors were encountered: