Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

new_bird-hyun

React의 고급 패턴 - Render Props 본문

코딩 공부

React의 고급 패턴 - Render Props

새혀니 2024. 12. 10. 09:33
import React, { useState } from 'react'; function MouseTracker({ render }) { const [position, setPosition] = useState({ x: 0, y: 0 }); const handleMouseMove = (e) => { setPosition({ x: e.clientX, y: e.clientY }); }; return (
{render(position)}
); } function App() { return ( (

마우스 위치: ({position.x}, {position.y})

)} /> ); } export default App;