Created
December 14, 2021 17:59
-
-
Save Lahirutech/82180b316189b053385a72b78d3af3fd to your computer and use it in GitHub Desktop.
This file contains hidden or 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, { useContext } from "react"; | |
| import { CountContext } from "../App"; | |
| function ComponentA() { | |
| const countContext = useContext(CountContext); | |
| return ( | |
| <div> | |
| Home page cart:{countContext.countState} | |
| <button onClick={() => countContext.countDispatch("increment")}> | |
| Add Item | |
| </button> | |
| <button onClick={() => countContext.countDispatch("decrement")}> | |
| Remove Item | |
| </button> | |
| <button onClick={() => countContext.countDispatch("reset")}>Clear</button> | |
| </div> | |
| ); | |
| } | |
| export default ComponentA; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment