Skip to content

Instantly share code, notes, and snippets.

@jeff3dx
jeff3dx / d3-in-react.js
Last active October 27, 2022 09:24
D3 in React with Hooks
import React, { useRef, useEffect } from 'react';
import * as d3 from 'd3';
interface IProps {
data?: number[];
}
/* Component */
export const MyD3Component = (props: IProps) => {
/* The useRef Hook creates a variable that "holds on" to a value across rendering