import React, { useState } from 'react' import ReactDOM from 'react-dom' import styles from './tooltip.module.css' const defWidth = 300 const defHeight = 250 export default function Tooltip({ children, text, opened, width, height }) { const [ref, setRef] = useState(React.createRef()) // eslint-disable-line const rect = ref.current ? ref.current.getBoundingClientRect() : null const h = height || defHeight // eslint-disable-line const w = width || defWidth // eslint-disable-line return ( {text && text()} {opened && ReactDOM.createPortal( {children} , document.body )} ) }