Skip to content

Commit

Permalink
sebastian review
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Mar 24, 2019
1 parent a41bb63 commit 8f61bfe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
2 changes: 0 additions & 2 deletions docs/src/pages/css-in-js/advanced/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ export default App;

## Server-side rendering

Material-UI supports concurrent server-side rendering.

This example returns a string of html and inlines the critical css required right before it’s used:

```jsx
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';

class ServerStyleSheets {
collect(children: React.ReactNode, options?: object): any;
declare class ServerStyleSheets {
constructor(options?: object);
collect(children: React.ReactNode, options?: object): void;
toString(): string;
getStyleElement(props?: object): React.ReactElement;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable react/no-danger */

import React from 'react';
import { SheetsRegistry } from 'jss';
import StylesProvider from '../StylesProvider';
Expand Down Expand Up @@ -32,13 +30,16 @@ class ServerStyleSheets {
}

getStyleElement(props) {
return (
<style
id="jss-server-side"
key="jss-server-side"
dangerouslySetInnerHTML={{ __html: this.toString() }}
{...props}
/>
return React.createElement(
'style',
Object.assign(
{
id: 'jss-server-side',
key: 'jss-server-side',
dangerouslySetInnerHTML: { __html: this.toString() },
},
props,
),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ function StylesProvider(props) {

warning(
typeof window !== 'undefined' || context.sheetsManager,
[
'Material-UI: you need to use the ServerStyleSheets API when rendering on the server.',
].join('\n'),
'Material-UI: you need to use the ServerStyleSheets API when rendering on the server.',
);

return <StylesContext.Provider value={context}>{children}</StylesContext.Provider>;
Expand Down

0 comments on commit 8f61bfe

Please sign in to comment.