mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 01:29:22 +00:00
Convert Shuffle to mapDispatchToProps
This commit is contained in:
parent
946537edf7
commit
8c635446a3
1 changed files with 12 additions and 18 deletions
|
|
@ -3,21 +3,15 @@ import {connect} from 'react-redux';
|
|||
import classnames from 'classnames';
|
||||
|
||||
|
||||
class Shuffle extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.handleClick = this.handleClick.bind(this);
|
||||
}
|
||||
handleClick() {
|
||||
this.props.dispatch({type: 'TOGGLE_SHUFFLE'});
|
||||
}
|
||||
render() {
|
||||
return <div
|
||||
id='shuffle'
|
||||
className={classnames({selected: this.props.shuffle})}
|
||||
onClick={this.handleClick}
|
||||
/>;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = connect((state) => state.media)(Shuffle);
|
||||
const Shuffle = ({shuffle, toggleShuffle}) => (
|
||||
<div
|
||||
id='shuffle'
|
||||
className={classnames({selected: shuffle})}
|
||||
onClick={toggleShuffle}
|
||||
/>
|
||||
);
|
||||
const mapStateToProps = (state) => state.media;
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
toggleShuffle: () => dispatch({type: 'TOGGLE_SHUFFLE'})
|
||||
});
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(Shuffle);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue