From c2bb644cf1c81f723dd709a411ca40d6380f0d6e Mon Sep 17 00:00:00 2001 From: Jeefelix <37668064+Jeefelix@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:37:10 -0300 Subject: [PATCH] refactoring useState to useReducer --- src/index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/index.js b/src/index.js index 1ce307b..43585f1 100644 --- a/src/index.js +++ b/src/index.js @@ -3,17 +3,21 @@ import ReactDOM from "react-dom"; import "./index.css"; export default function App() { - //first argument: what we want to do if setNumber has called? - // 0: the initial state - const [number, setNumber] = useReducer( - (number, newNumber) => number + newNumber, - 0 - ); + const [checked, toggle] = useReducer( + (checked) => !checked, false); - return
{checked ? "checked" : "no checked"}
+