Skip to content

Commit

Permalink
Put more emphasis on storing anchor in local state
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Sep 14, 2022
1 parent 1d11ed2 commit caacb0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/components/src/popover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const MyPopover = () => {
};
```

In order to pass an explicit anchor, you can use the `anchor` prop. When doing so, the anchor element should be stored in state rather than a plain ref to ensure reactive updating when it changes.
In order to pass an explicit anchor, you can use the `anchor` prop. When doing so, **the anchor element should be stored in local state** rather than a plain React ref to ensure reactive updating when it changes.

```jsx
import { Button, Popover } from '@wordpress/components';
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/popover/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export type PopoverProps = {
* The element that should be used by the popover as its anchor. It can either
* be an `Element` or, alternatively, a `VirtualElement` — ie. an object with
* the `getBoundingClientRect()` and the `ownerDocument` properties defined.
*
* **The anchor element should be stored in local state** rather than a
* plain React ref to ensure reactive updating when it changes.
*/
anchor?: Element | VirtualElement | null;
/**
Expand Down

0 comments on commit caacb0e

Please sign in to comment.