Created
March 26, 2025 11:09
-
-
Save h-agharezaei/c87d147877d783f878565f347d4d6942 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, useCallback } from "react"; | |
| function Button({ onClick }) { | |
| console.log("🎯 دکمه رندر شد"); | |
| return <button onClick={onClick}>افزایش</button>; | |
| } | |
| export default function App() { | |
| const [count, setCount] = useState(0); | |
| const increment = useCallback(() => { | |
| setCount((prev) => prev + 1); | |
| }, []); // این تابع فقط یک بار ساخته میشود | |
| return ( | |
| <div> | |
| <p>Count: {count}</p> | |
| <Button onClick={increment} /> | |
| </div> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment