Last active
October 3, 2020 05:49
-
-
Save itaditya/ecc0ae38ef60386a0677d617a3b806f0 to your computer and use it in GitHub Desktop.
(Blog) Build a Redux hooked app
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
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