Refactor class components to SFC
This commit is contained in:
parent
72f9d435fb
commit
79fd6a2512
|
|
@ -1,6 +1,6 @@
|
||||||
import Button from 'material-ui/Button';
|
import Button from 'material-ui/Button';
|
||||||
import Dialog, {DialogActions, DialogContent, DialogContentText, DialogTitle} from 'material-ui/Dialog';
|
import Dialog, {DialogActions, DialogContent, DialogContentText, DialogTitle} from 'material-ui/Dialog';
|
||||||
import React, {Component} from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
title: string
|
title: string
|
||||||
|
|
@ -9,9 +9,7 @@ interface IProps {
|
||||||
fOnSubmit: VoidFunction
|
fOnSubmit: VoidFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ConfirmDialog extends Component<IProps> {
|
export default function ConfirmDialog({title, text, fClose, fOnSubmit}: IProps) {
|
||||||
public render() {
|
|
||||||
const {title, text, fClose, fOnSubmit} = this.props;
|
|
||||||
const submitAndClose = () => {
|
const submitAndClose = () => {
|
||||||
fOnSubmit();
|
fOnSubmit();
|
||||||
fClose();
|
fClose();
|
||||||
|
|
@ -29,4 +27,3 @@ export default class ConfirmDialog extends Component<IProps> {
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,12 @@ interface IProps {
|
||||||
style?: object,
|
style?: object,
|
||||||
}
|
}
|
||||||
|
|
||||||
class Container extends React.Component<IProps & WithStyles<'paper'>, {}> {
|
const Container: React.SFC<IProps & WithStyles<'paper'>> = ({classes, children, style}) => {
|
||||||
public render() {
|
|
||||||
const {classes, children, style} = this.props;
|
|
||||||
return (
|
return (
|
||||||
<Paper elevation={6} className={classes.paper} style={style}>
|
<Paper elevation={6} className={classes.paper} style={style}>
|
||||||
{children}
|
{children}
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
export default withStyles(styles)<IProps>(Container);
|
export default withStyles(styles)<IProps>(Container);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import Grid from 'material-ui/Grid';
|
import Grid from 'material-ui/Grid';
|
||||||
import {CircularProgress} from 'material-ui/Progress';
|
import {CircularProgress} from 'material-ui/Progress';
|
||||||
import React, {Component} from 'react';
|
import React from 'react';
|
||||||
import DefaultPage from './DefaultPage';
|
import DefaultPage from './DefaultPage';
|
||||||
|
|
||||||
class LoadingSpinner extends Component {
|
export default function LoadingSpinner() {
|
||||||
public render() {
|
|
||||||
return (
|
return (
|
||||||
<DefaultPage title="" maxWidth={250} hideButton={true}>
|
<DefaultPage title="" maxWidth={250} hideButton={true}>
|
||||||
<Grid item xs={12} style={{textAlign: 'center'}}>
|
<Grid item xs={12} style={{textAlign: 'center'}}>
|
||||||
|
|
@ -12,7 +11,4 @@ class LoadingSpinner extends Component {
|
||||||
</Grid>
|
</Grid>
|
||||||
</DefaultPage>
|
</DefaultPage>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
export default LoadingSpinner;
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import Delete from 'material-ui-icons/Delete';
|
||||||
import IconButton from 'material-ui/IconButton';
|
import IconButton from 'material-ui/IconButton';
|
||||||
import {withStyles} from 'material-ui/styles';
|
import {withStyles} from 'material-ui/styles';
|
||||||
import Typography from 'material-ui/Typography';
|
import Typography from 'material-ui/Typography';
|
||||||
import React, {Component} from 'react';
|
import React from 'react';
|
||||||
import TimeAgo from 'react-timeago';
|
import TimeAgo from 'react-timeago';
|
||||||
import Container from './Container';
|
import Container from './Container';
|
||||||
|
|
||||||
|
|
@ -42,10 +42,7 @@ interface IProps {
|
||||||
fDelete: VoidFunction
|
fDelete: VoidFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
class Message extends Component<IProps & Style> {
|
function Message({fDelete, classes, title, date, content, image}: IProps & Style) {
|
||||||
public render() {
|
|
||||||
const {fDelete, classes, title, date, content, image} = this.props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.wrapperPadding}>
|
<div className={classes.wrapperPadding}>
|
||||||
<Container style={{display: 'flex'}}>
|
<Container style={{display: 'flex'}}>
|
||||||
|
|
@ -68,6 +65,5 @@ class Message extends Component<IProps & Style> {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default withStyles(styles)<IProps>(Message);
|
export default withStyles(styles)<IProps>(Message);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue