Skip to content

Instantly share code, notes, and snippets.

@clamstew
Forked from indreklasn/Toggle.js
Created June 20, 2019 13:39
Show Gist options
  • Save clamstew/2f2ccdb51f1213a4069303bbf9fc2c45 to your computer and use it in GitHub Desktop.
Save clamstew/2f2ccdb51f1213a4069303bbf9fc2c45 to your computer and use it in GitHub Desktop.
import React from "react";
import { useSelector, useDispatch } from "react-redux";
import { TOGGLE } from "./UiReducer";
const Toggle = () => {
const ui = useSelector(state => state.ui);
const dispatch = useDispatch();
return (
<div>
<div>{JSON.stringify(ui)}</div>
<input
type="checkbox"
value={ui.toggle}
onChange={() => dispatch({ type: TOGGLE })}
/>
</div>
);
};
export default Toggle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment