Buckets:
| import { useSelector, useDispatch } from "react-redux"; | |
| const useCounter = () => { | |
| const count = useSelector((state) => state.count); | |
| const dispatch = useDispatch(); | |
| const increment = () => | |
| dispatch({ | |
| type: "INCREMENT", | |
| }); | |
| const decrement = () => | |
| dispatch({ | |
| type: "DECREMENT", | |
| }); | |
| const reset = () => | |
| dispatch({ | |
| type: "RESET", | |
| }); | |
| return { count, increment, decrement, reset }; | |
| }; | |
| const Counter = () => { | |
| const { count, increment, decrement, reset } = useCounter(); | |
| return ( | |
| <div> | |
| <h1> | |
| Count: <span>{count}</span> | |
| </h1> | |
| <button onClick={increment}>+1</button> | |
| <button onClick={decrement}>-1</button> | |
| <button onClick={reset}>Reset</button> | |
| </div> | |
| ); | |
| }; | |
| export default Counter; | |
Xet Storage Details
- Size:
- 786 Bytes
- Xet hash:
- 5300ecd01333dda1f48580f374a73fe1aa1ea75a96ca783c847fe74bf8ad045c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.