Skip to content

Instantly share code, notes, and snippets.

@rubenmarcus
Last active March 25, 2020 21:11
Show Gist options
  • Save rubenmarcus/226ae137d0c9633787a3ee385da1613a to your computer and use it in GitHub Desktop.
Save rubenmarcus/226ae137d0c9633787a3ee385da1613a to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
import { connect } from "react-redux";
import { toggleSwitch } from "./UiReducer";
class Toggle extends Component {
render() {
const { ui, toggleSwitch } = this.props;
return (
<div>
<div>{JSON.stringify(ui)}</div>
<input
type="checkbox"
value={ui.toggle}
onChange={toggleSwitch}
/>
</div>
);
}
}
const mapStateToProps = ({ ui }) => ({
ui
});
export default connect(
mapStateToProps,
{ toggleSwitch }
)(Toggle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment