Last active
December 6, 2019 20:52
-
-
Save shanebdavis/23b0bb496838ba43fe91135be974e2f5 to your computer and use it in GitHub Desktop.
This file contains 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 ReactDOM from "react-dom"; | |
import { Provider, useRedux } from "hooks-for-redux"; | |
import "./styles.css"; | |
// toggleState.js | |
const [useToggle, { toggleSwitch }] = useRedux("toggle", false, { | |
toggleSwitch: state => !state | |
}); | |
// Toggle.js | |
const Toggle = () => { | |
const toggle = useToggle(); | |
return ( | |
<div> | |
<div>{JSON.stringify(toggle)}</div> | |
<input type="checkbox" value={toggle} onChange={toggleSwitch} /> | |
</div> | |
); | |
}; | |
// index.js | |
const App = () => <Provider><Toggle /></Provider> | |
const rootElement = document.getElementById("root"); | |
ReactDOM.render(<App />, rootElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment