Last active
February 13, 2017 23:59
-
-
Save christiannaths/209fb2aa799b089e3eaf97d84bba55ad to your computer and use it in GitHub Desktop.
my-app/src/components/notifications-switch.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import { connect } from 'react-redux' | |
| import { actions } from '../store/actions' | |
| const mapStateToProps = (state) => ({ | |
| notifications: state.settings.notifications | |
| }) | |
| const NotificationsSwitch = ({notifications, dispatch}) => ( | |
| <label> | |
| <span>Notifications</span> | |
| <input | |
| type='checkbox' | |
| checked={notifications} | |
| onChange={(event) => { | |
| dispatch(actions.setNotifications(event.target.checked)) | |
| }} | |
| /> | |
| </label> | |
| ) | |
| export default connect(mapStateToProps)(NotificationsSwitch) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment