Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

On mouse click - object mapping

Public visualization

Viewing a saved revision (read-only)

c623a145dbca4652a8118ea302ee9203

On mouse click - object mapping

0 stars1🌍 Public
NNita
Last edited May 28, 2020
Created on May 28, 2020

This example demonstrates how user interaction can be directly mapped to an SVG object’s position. A green circle updates its coordinates based on mouse clicks on the React-rendered SVG. The code uses React’s `useState` and `useCallback` hooks to track the mouse position, with initial data from the `array` constant. The `onClick` event handler triggers a state update, which re-renders the circle at the clicked location using SVG circle elements.

AI-generated description

React Starter code.