Last active
November 6, 2021 08:47
-
-
Save MassivDash/86a152e762975f2601ff3895830be89e to your computer and use it in GitHub Desktop.
useD3 react hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import * as d3 from 'd3'; | |
export const useD3 = (renderChartFn, dependencies) => { | |
const ref = React.useRef(); | |
React.useEffect(() => { | |
renderChartFn(d3.select(ref.current)); | |
return () => {}; | |
}, dependencies); | |
return ref; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment