Skip to content

Commit

Permalink
docs: update popover custom target story (#31374)
Browse files Browse the repository at this point in the history
  • Loading branch information
spmonahan committed May 16, 2024
1 parent cafe42c commit 30e870e
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const ExampleContent = () => {
};

export const AnchorToCustomTarget = () => {
const buttonRef = React.useRef<HTMLButtonElement>(null);
const positioningRef = React.useRef<PositioningImperativeRef>(null);
const styles = useStyles();
const buttonRef = React.useCallback(
(el: HTMLButtonElement | null) => {
positioningRef.current?.setTarget(el);
},
[positioningRef],
);

React.useEffect(() => {
if (buttonRef.current) {
positioningRef.current?.setTarget(buttonRef.current);
}
}, [buttonRef, positioningRef]);
const styles = useStyles();

return (
<div className={styles.container}>
Expand Down

0 comments on commit 30e870e

Please sign in to comment.