import React, { useState } from "react";
const white = () => {
return "white";
};
export default function Counter() {
const [count, setCount] = useState(15);
const [currentState, setUpdateCurrentStateFunction] = useState(() => white());
function plus() {
setCount((prevCount) => prevCount + 1);
}
function minus() {
setCount((prevCount) => prevCount - 1);
}
function changeColor() {
setUpdateCurrentStateFunction("yellow");
}
return (
<div>
<button className="plus" onClick={plus}>
+
</button>
<p>{count}</p>
<p>{currentState}</p>
<button className="minus" onClick={minus}>
-
</button>
<button onClick={changeColor}>CHANGE COLOR</button>
</div>
);
}