3 ms·
I couldn't see a reason for React to be used in this visualization either. It's been awhile since I've used D3 but I thought it could do this kind of rendering
by danso 7y ago
I couldn't see a reason for React to be used in this visualization either. It's been awhile since I've used D3 but I thought it could do this kind of rendering on its own?
<svg
width={width}
height={height}
>
{geoJson.features.map(feature =>
<path
key={`path-${feature.properties.bfsId}`}
stroke='white'
strokeWidth={0.25}
d={path(feature)}
fill='steelblue'
/>
)}
</svg>
I was thinking maybe React was also used with this visualization in production (e.g. adding interactive elements for a published story), and so maybe the author found it easy to use React for the rendering too?
- sen_mendoza 7y agoD3 can do this type of rendering, but d3 data joins and selections are often difficult for people to understand and master. The beauty of this approach is that it bypasses all that and uses map to loop through the geoJSON features creating each path element. To me this is more readable and easy to understand, but you don't really need react to do any of this. This can also be done with plan js.
- sccxy 7y agoI think biggest reason to use React was great create-react-app for developer setup. Fast and easy to start and expand as needed.