Skip to content

Instantly share code, notes, and snippets.

@itaditya
Last active October 3, 2020 05:49
Show Gist options
  • Save itaditya/ecc0ae38ef60386a0677d617a3b806f0 to your computer and use it in GitHub Desktop.
Save itaditya/ecc0ae38ef60386a0677d617a3b806f0 to your computer and use it in GitHub Desktop.
(Blog) Build a Redux hooked app
export default function App() {
const diet = useSelector((state) => state.diet);
const dispatch = useDispatch();
function handleVegToggle() {
dispatch({
type: ACTIONS.CHANGE_DIET,
});
}
return (
<div className="food-app">
// rest of the code
<label>
<input
type="checkbox"
name="veg-checkbox"
value={diet}
checked={diet === 'veg'}
onChange={handleVegToggle}
/>
Veg Only
</label>
// rest of the code
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment