diff --git a/polydodo/src/components/d3component.js b/polydodo/src/components/d3component.js index 245bb0e7..3a92e6fa 100644 --- a/polydodo/src/components/d3component.js +++ b/polydodo/src/components/d3component.js @@ -1,23 +1,9 @@ -import React from "react"; -import PropTypes from "prop-types"; +import React, { useEffect, useRef } from "react"; -class D3Component extends React.Component { - static propTypes = { - callback: PropTypes.func.isRequired, - } +const D3Component = React.memo(({ callback }) => { + const ref = useRef(); + useEffect(() => callback(ref.current)); + return ; +}); - componentDidMount() { - const { callback } = this.props; - callback(this.svg); - } - - shouldComponentUpdate() { - return false; - } - - render() { - return ( this.svg = ref } />); - } -} - -export default D3Component; \ No newline at end of file +export default D3Component;