Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update docs
  • Loading branch information
getdave committed Sep 20, 2023
commit baf4546813cfac6ab86fca58168aa84fc952fe90
24 changes: 24 additions & 0 deletions packages/block-editor/src/components/link-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@ The resulting default properties of `value` include:
- `title` (`string`, optional): Link title.
- `opensInNewTab` (`boolean`, optional): Whether link should open in a new browser tab. This value is only assigned when not providing a custom `settings` prop.

Note that as `<LinkControl>` is often rendered within other components that may themselves re-render it is advisable that consumers memoize the `value` prop before passing it to the component. This avoids re-renders of LinkControl which may result in unwanted loss of
changes users have may made when interacting with the control prior to the re-rendering.

```jsx
const memoizedValue = useMemo(
() => ( {
url: attributes.url,
type: attributes.type,
opensInNewTab: attributes.target === '_blank',
title: attributes.text,
} ),
[
attributes.url,
attributes.type,
attributes.target,
attributes.text,
]
);

<LinkControl
value={ memoizedValue }
>
```

### settings

- Type: `Array`
Expand Down