Created
March 24, 2025 10:33
-
-
Save h-agharezaei/bb4a0607427439a24332db2104fcd30d 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 { useState, useEffect } from "react"; | |
function Component() { | |
const [count, setCount] = useState(0); | |
const [text, setText] = useState(""); | |
useEffect(() => { | |
console.log("Count updated:", count); | |
}, [count, text]); // مشکل: این اثر هر بار که count یا text تغییر کند اجرا میشود | |
return ( | |
<div> | |
<p>Count: {count}</p> | |
<button onClick={() => setCount(count + 1)}>افزایش</button> | |
<input value={text} onChange={(e) => setText(e.target.value)} /> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment