I am a beginner, trying to understand react-popper. On their github, this is the example code:
import { Manager, Reference, Popper } from 'react-popper';
const Example = () => (
<Manager>
<Reference>
{({ ref }) => (
<button type="button" ref={ref}>
Reference element
</button>
)}
</Reference>
<Popper placement="right">
{({ ref, style, placement, arrowProps }) => (
<div ref={ref} style={style} data-placement={placement}>
Popper element
<div ref={arrowProps.ref} style={arrowProps.style} />
</div>
)}
</Popper>
</Manager>
);
Is this as it stands there supposed to be working? I am not sure I understand how I could use this code, how it would look like if I were to import/use this Example Component into my own parent component; Would I need to pass refs? How so? It would be great if somebody could give me a working example of this code, I'd just like to see how to make use of this.
Don't bother too much with the render props. In most of the cases, you won't need to modify them.
Just keep in mind that
refrender prop fromReferenceshould be attached to the reference element (your item where is attached your popper).refrender prop fromPoppershould be attached on the popper (your tooltip or whatever).styleandplacementrender prop is for the geographical position on the page.In resume, this example will render a button with an arrowed popperized
<div>which contains"Popper element".