From 97ca2e9d94fabe2b22c20fd8e2331d20a28b23e5 Mon Sep 17 00:00:00 2001 From: uwap Date: Sun, 2 Sep 2018 13:24:55 +0200 Subject: [PATCH] Convert pure Components to functions --- src/components/SideBar.js | 82 ++++++++++++++++----------------------- src/components/TopBar.js | 43 ++++++++------------ 2 files changed, 49 insertions(+), 76 deletions(-) diff --git a/src/components/SideBar.js b/src/components/SideBar.js index afea280..94e1570 100644 --- a/src/components/SideBar.js +++ b/src/components/SideBar.js @@ -21,57 +21,41 @@ export type SideBarProps = { children?: React.Node }; -export type SideBarState = { -}; - type Props = SideBarProps & Classes; -class SideBar extends React.PureComponent { - constructor(props: Props) { - super(props); - } +const SideBar = (props: Props) => ( + + + + + {props.icon == null || renderRawIcon(props.icon, "mdi-36px")} + + + {props.control == null ? "" : props.control.name} + + + + + + + + {props.children} + + +); - static styles(): Object { - return { - drawerPaper: { - width: 340 - }, - flex: { - flex: 1 - } - }; +const styles = { + drawerPaper: { + width: 340 + }, + flex: { + flex: 1 } +}; - close() { - this.props.onCloseRequest(); - } - - render() { - return ( - - - - {this.props.icon == null - || renderRawIcon(this.props.icon, "mdi-36px")} - - {this.props.control == null ? "" : this.props.control.name} - - - - - - - - {this.props.children} - - - ); - } -} - -export default withStyles(SideBar.styles)(SideBar); +export default withStyles(styles)(SideBar); diff --git a/src/components/TopBar.js b/src/components/TopBar.js index 0d4953f..c40d139 100644 --- a/src/components/TopBar.js +++ b/src/components/TopBar.js @@ -11,33 +11,22 @@ export type TopBarProps = { connected: boolean }; -export type TopBarState = { - +const renderConnectionIndicator = (connected: boolean) => { + if (connected) { + return (); + } + return ( + + ); }; -export default class TopBar - extends React.PureComponent { - constructor(props: TopBarProps) { - super(props); - } +const TopBar = (props: TopBarProps) => ( + + + {renderConnectionIndicator(props.connected)} + {props.title} + + +); - render() { - return ( - - - {this.renderConnectionIndicator()} - {this.props.title} - - - ); - } - - renderConnectionIndicator() { - if (this.props.connected) { - return (); - } - return ( - - ); - } -} +export default TopBar;