Skip to content

Instantly share code, notes, and snippets.

@christiannaths
Last active February 13, 2017 23:59
Show Gist options
  • Select an option

  • Save christiannaths/209fb2aa799b089e3eaf97d84bba55ad to your computer and use it in GitHub Desktop.

Select an option

Save christiannaths/209fb2aa799b089e3eaf97d84bba55ad to your computer and use it in GitHub Desktop.
my-app/src/components/notifications-switch.js
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