Skip to content

Commit

Permalink
[NoSSR] Add a fallback property
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 18, 2018
1 parent 91e355a commit b0b2bb2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
Expand Up @@ -57,7 +57,7 @@ class DynamicCSSVariables extends React.Component {
}
}
>
{'dynamic CSS variables'}
{'CSS variables'}
</Button>
</React.Fragment>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/overrides/DynamicClassName.js
Expand Up @@ -51,7 +51,7 @@ class DynamicClassName extends React.Component {
[classes.buttonBlue]: this.state.color === 'blue',
})}
>
{'dynamic class names'}
{'Class name branch'}
</Button>
</React.Fragment>
);
Expand Down
Expand Up @@ -47,7 +47,7 @@ class DynamicThemeNesting extends React.Component {
}
>
<Button variant="raised" color="secondary">
{'dynamic theme nesting'}
{'Theme nesting'}
</Button>
</MuiThemeProvider>
</React.Fragment>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/overrides/overrides.md
Expand Up @@ -136,7 +136,7 @@ It will come with: [#7633](https://github.com/mui-org/material-ui/issues/7633).

{{"demo": "pages/customization/overrides/DynamicCSSVariables.js"}}

### Dynamic inline style
### Inline-style

{{"demo": "pages/customization/overrides/DynamicInlineStyle.js"}}

Expand Down
11 changes: 9 additions & 2 deletions packages/material-ui-docs/src/NoSSR/NoSSR.js
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';

const DefaultOnSSR = () => null;
const Fallback = () => null;

/**
* Only render the component on the client.
Expand All @@ -21,12 +21,19 @@ class NoSSR extends React.Component {
}

render() {
return this.state.mounted ? this.props.children : <DefaultOnSSR />;
const { children, fallback } = this.props;

return this.state.mounted ? children : fallback;
}
}

NoSSR.propTypes = {
children: PropTypes.node.isRequired,
fallback: PropTypes.node,
};

NoSSR.defaultProps = {
fallback: <Fallback />,
};

export default NoSSR;
6 changes: 1 addition & 5 deletions packages/material-ui/src/GridListTile/GridListTile.js
Expand Up @@ -52,11 +52,7 @@ class GridListTile extends React.Component {
fit = () => {
const imgElement = this.imgElement;

if (!imgElement) {
return;
}

if (!imgElement.complete) {
if (!imgElement || !imgElement.complete) {
return;
}

Expand Down

0 comments on commit b0b2bb2

Please sign in to comment.