Skip to main content
100%

React Hooks Bowl of Fruit

✓ Published0🌍 Public
MMartin Blatz
Last edited Sep 30, 2020
Created on Sep 30, 2020

A React Hooks component renders a static bowl of five red apples as SVG circles, with clicking one highlighting it via a black stroke. The code uses `useState` to manage the selected fruit ID and passes the selection handler down to the `FruitBowl` component. D3’s `scaleOrdinal` maps fruit types to colors and radii, while `range` generates the initial fruit array. The example demonstrates integrating D3 scales with React’s declarative rendering model, though commented-out code hints at possible transitions that are not active in this version.

AI-generated description

Trying out React Hooks.

MIT Licensed

Similar vizzes