Skip to main content
100%

Basic React Hook Test (Circles - Fixed Data)

✓ Published1🌍 Public
TTom-S82
Last edited Feb 17, 2020
Created on Feb 16, 2020
Forked from Smiley Face Part 1

This example demonstrates how React hooks can manage D3-driven SVG circle updates with fixed data. The app initializes an array of seven values, rendering each as a grey circle with a blue stroke, positioned via attributes calculated from the data. Two buttons trigger state changes: “Update Data” adds five to every value, while “Filter Data” removes values above 35, causing D3’s join method to add, remove, or update circles accordingly. The code uses the `useRef`, `useState`, and `useEffect` hooks, alongside `d3.select` and `.join()`, with React 16.12 and D3 v5.

AI-generated description

Following along with Muri's basic tutorial on how to set up React hooks with D3.

MIT Licensed

Similar vizzes