-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59759c2
commit 0efc81d
Showing
20 changed files
with
166 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import NoSsr from '@material-ui/core/NoSsr'; | ||
import Button from '@material-ui/core/Button'; | ||
|
||
const styles = theme => ({ | ||
button: { | ||
display: 'block', | ||
margin: theme.spacing.unit * 2, | ||
}, | ||
}); | ||
|
||
function SimpleNoSsr(props) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<div> | ||
<Button className={classes.button} variant="contained" color="primary"> | ||
Server & Client | ||
</Button> | ||
<NoSsr> | ||
<Button className={classes.button} variant="contained" color="secondary"> | ||
Client only | ||
</Button> | ||
</NoSsr> | ||
</div> | ||
); | ||
} | ||
|
||
SimpleNoSsr.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(SimpleNoSsr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: No SSR React component | ||
components: NoSsr | ||
--- | ||
|
||
# No SSR | ||
|
||
<p class="description">NoSsr purposely removes components from the subject of Server Side Rendering (SSR).</p> | ||
|
||
This component can be useful in a variety of situations: | ||
- Escape hatch for broken dependencies not supporting SSR. | ||
- Improve the time-to-first paint on the client by only rendering above the fold. | ||
- Reduce the rendering time on the server. | ||
- Under too heavy server load, you can turn on service degradation. | ||
|
||
{{"demo": "pages/utils/no-ssr/SimpleNoSsr.js"}} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
|
||
export interface NoSsrProps { | ||
children: React.ReactNode; | ||
fallback?: React.ReactNode; | ||
} | ||
|
||
declare const NoSsr: React.ComponentType<NoSsrProps>; | ||
|
||
export default NoSsr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './NoSsr'; | ||
export * from './NoSsr'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './NoSsr'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import withRoot from 'docs/src/modules/components/withRoot'; | ||
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; | ||
import markdown from './no-ssr.md'; | ||
|
||
function Page() { | ||
return <MarkdownDocs markdown={markdown} />; | ||
} | ||
|
||
export default withRoot(Page); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
filename: /packages/material-ui/src/NoSsr/NoSsr.js | ||
title: NoSsr API | ||
--- | ||
|
||
<!--- This documentation is automatically generated, do not try to edit it. --> | ||
|
||
# NoSsr | ||
|
||
<p class="description">The API documentation of the NoSsr React component.</p> | ||
|
||
NoSsr purposely removes components from the subject of Server Side Rendering (SSR). | ||
|
||
This component can be useful in a variety of situations: | ||
- Escape hatch for broken dependencies not supporting SSR. | ||
- Improve the time-to-first paint on the client by only rendering above the fold. | ||
- Reduce the rendering time on the server. | ||
- Under too heavy server load, you can turn on service degradation. | ||
|
||
## Props | ||
|
||
| Name | Type | Default | Description | | ||
|:-----|:-----|:--------|:------------| | ||
| <span class="prop-name required">children *</span> | <span class="prop-type">node | | | | ||
| <span class="prop-name">fallback</span> | <span class="prop-type">node | <span class="prop-default"><Fallback /></span> | | | ||
|
||
Any other properties supplied will be spread to the root element (native element). | ||
|
||
## Demos | ||
|
||
- [No Ssr](/utils/no-ssr) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import withRoot from 'docs/src/modules/components/withRoot'; | ||
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; | ||
import markdown from 'docs/src/pages/utils/no-ssr/no-ssr.md'; | ||
|
||
function Page() { | ||
return ( | ||
<MarkdownDocs | ||
markdown={markdown} | ||
demos={{ | ||
'pages/utils/no-ssr/SimpleNoSsr.js': { | ||
js: require('docs/src/pages/utils/no-ssr/SimpleNoSsr').default, | ||
raw: preval` | ||
module.exports = require('fs') | ||
.readFileSync(require.resolve('docs/src/pages/utils/no-ssr/SimpleNoSsr'), 'utf8') | ||
`, | ||
}, | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
export default withRoot(Page); |