Skip to content

Instantly share code, notes, and snippets.

@h-agharezaei
Created March 26, 2025 11:09
Show Gist options
  • Select an option

  • Save h-agharezaei/c87d147877d783f878565f347d4d6942 to your computer and use it in GitHub Desktop.

Select an option

Save h-agharezaei/c87d147877d783f878565f347d4d6942 to your computer and use it in GitHub Desktop.
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