src/App.tsx
export default function App() {
const handleCapture = () => {
console.log('Parent');
};
const handleBubble = () => {
console.log('Child');
};
return (
<div
onClick={handleCapture}
style={{ padding: '50px', backgroundColor: '#f0f0f0' }}
>Parent
<button onClick={handleBubble} style={{ marginTop: '20px' }}
>Click Me</button>
</div>
);
}
애플리케이션을 실행하고 버튼을 클릭하면 Child → Parent 순으로 로그가 출력됩니다.