Skip to main content
100%

Smiley Face Follower - using hooks

✓ Published0🌍 Public
Aalexislanz
Last edited Aug 3, 2021
Created on Aug 3, 2021

A smiling face follows the mouse cursor across an SVG canvas, updating its position in real time. The example uses React hooks, specifically `useState`, to track mouse coordinates via an `onMouseMove` event handler on the `<svg>` element, and re-renders the face accordingly. The face is composed of reusable React components—`FaceContainer`, `BackgroundCircle`, `Eyes`, and `Mouth`—where the mouth shape is generated using the `d3.arc()` function from D3 v7. All rendering is done declaratively in SVG.

AI-generated description

A Smiley that follows your mouse.

Why does it clip on movement?

MIT Licensed

Similar vizzes