@maktouch/use-popper
v1.3.0
Published
![npm](https://img.shields.io/npm/dt/use-popper.svg) ![npm](https://img.shields.io/npm/v/use-popper.svg) ![NpmLicense](https://img.shields.io/npm/l/use-popper.svg)
Downloads
5
Readme
Use Popper
Installation
Note: React 16.8+ is required for Hooks.
With npm
npm i use-popper
Or with yarn
yarn add use-popper
import React from 'react';
import usePopper from 'use-popper';
import { useHover } from 'use-events';
function Tooltip(props) {
const { referrence, popper, arrow } = usePopper({ placement: 'bottom' });
const [active, bind] = useHover();
return (
<div>
<button ref={referrence.ref} {...bind}>
hover me
</button>
{active && (
<div
ref={popper.ref}
style={popper.styles}
data-placement={popper.placement}
>
<div>Hello!</div>
<div ref={arrow.ref} style={arrow.styles} />
</div>
)}
</div>
);
}
export default Tooltip;