Skip to content

Commit

Permalink
[docs] Temporary fix for SSR issue with Portal (#8907)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Oct 30, 2017
1 parent 9ea0d4d commit 836c01c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
18 changes: 11 additions & 7 deletions docs/src/modules/components/NoSSR.js
@@ -1,11 +1,19 @@
/* eslint-disable flowtype/require-valid-file-annotation */
// @flow

import React from 'react';
import PropTypes from 'prop-types';
import type { Node } from 'react';

const DefaultOnSSR = () => null;

class NoSSR extends React.Component {
type State = {
canRender: boolean,
};

type Props = {
children: Node,
};

class NoSSR extends React.Component<Props, State> {
state = {
canRender: false,
};
Expand All @@ -19,8 +27,4 @@ class NoSSR extends React.Component {
}
}

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

export default NoSSR;
47 changes: 25 additions & 22 deletions docs/src/pages/demos/dialogs/AlertDialogSlide.js
Expand Up @@ -9,6 +9,7 @@ import Dialog, {
DialogTitle,
} from 'material-ui/Dialog';
import Slide from 'material-ui/transitions/Slide';
import NoSSR from 'docs/src/modules/components/NoSSR'; // Temporary workaround for SSR Portal issue.

function Transition(props) {
return <Slide direction="up" {...props} />;
Expand All @@ -31,28 +32,30 @@ export default class AlertDialogSlide extends React.Component {
return (
<div>
<Button onClick={this.handleClickOpen}>Slide in alert dialog</Button>
<Dialog
open={this.state.open}
transition={Transition}
keepMounted
onRequestClose={this.handleRequestClose}
>
<DialogTitle>{"Use Google's location service?"}</DialogTitle>
<DialogContent>
<DialogContentText>
Let Google help apps determine location. This means sending anonymous location data to
Google, even when no apps are running.
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={this.handleRequestClose} color="primary">
Disagree
</Button>
<Button onClick={this.handleRequestClose} color="primary">
Agree
</Button>
</DialogActions>
</Dialog>
<NoSSR>
<Dialog
open={this.state.open}
transition={Transition}
keepMounted
onRequestClose={this.handleRequestClose}
>
<DialogTitle>{"Use Google's location service?"}</DialogTitle>
<DialogContent>
<DialogContentText>
Let Google help apps determine location. This means sending anonymous location data
to Google, even when no apps are running.
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={this.handleRequestClose} color="primary">
Disagree
</Button>
<Button onClick={this.handleRequestClose} color="primary">
Agree
</Button>
</DialogActions>
</Dialog>
</NoSSR>
</div>
);
}
Expand Down
1 change: 0 additions & 1 deletion src/transitions/Slide.js
Expand Up @@ -154,7 +154,6 @@ class Slide extends React.Component<ProvidedProps & Props, State> {
}

transition = null;
firstRender = false;

handleResize = debounce(() => {
// Skip configuration where the position is screen size invariant.
Expand Down

0 comments on commit 836c01c

Please sign in to comment.