Frontendx
README.md
SOLUTION.md
main.tsxentry
App.tsx
App.css
index.html
vite.config.ts
Installed
react@^19.2.0
react-dom@^19.2.0

Render Props Pattern

mediumreactpatternsrender-propsReact Patterns

Description

Implement a MouseTracker component using the render props pattern to track mouse position.

Example 1:

<MouseTracker render={(x, y) => (
  <p>Mouse is at {x}, {y}</p>
)} />

Example 2:

<MouseTracker>
  {(x, y) => <div style={{position: 'absolute', left: x, top: y}}>●</div>}
</MouseTracker>

Constraints

  • Create a MouseTracker component that tracks mouse position
  • Use render props pattern - accept a function as children or render prop
  • Pass x and y coordinates to the render function
  • Track mousemove events on window or document
  • Clean up event listener on unmount
Render prop is a function prop that tells component what to render
Test Results

Render Props Pattern

Implement the render props pattern to share component logic using a function prop.