From 16a3be5f3192ca7791e1bd4d20af0ce71429b533 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 31 Dec 2016 11:43:14 -0800 Subject: [PATCH] Convert ClutterBar to mapDispatchToProps --- js/components/ClutterBar.jsx | 53 ++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/js/components/ClutterBar.jsx b/js/components/ClutterBar.jsx index dba20408..7d61463e 100644 --- a/js/components/ClutterBar.jsx +++ b/js/components/ClutterBar.jsx @@ -3,36 +3,31 @@ import {connect} from 'react-redux'; import classnames from 'classnames'; -class ClutterBar extends React.Component { - constructor(props) { - super(props); - this.handleMouseDownDouble = this.handleMouseDownDouble.bind(this); - this.handleMouseUpDouble = this.handleMouseUpDouble.bind(this); - } +const ClutterBar = (props) => ( +
+
+
+
+
+
+
+); - handleMouseDownDouble() { - this.props.dispatch({type: 'SET_FOCUS', input: 'double'}); - } +const mapStateToProps = (state) => ({ + doubled: state.display.doubled +}); - handleMouseUpDouble() { - this.props.dispatch({type: 'TOGGLE_DOUBLESIZE_MODE'}); - this.props.dispatch({type: 'UNSET_FOCUS'}); +const mapDispatchToProps = (dispatch) => ({ + handleMouseDown: () => dispatch({type: 'SET_FOCUS', input: 'double'}), + handleMouseUp: () => { + dispatch({type: 'TOGGLE_DOUBLESIZE_MODE'}); + dispatch({type: 'UNSET_FOCUS'}); } +}); - render() { - return
-
-
-
-
-
-
; - } -} - -module.exports = connect((state) => state.display)(ClutterBar); +module.exports = connect(mapStateToProps, mapDispatchToProps)(ClutterBar);