Skip to content

Commit

Permalink
Merge pull request #34 from labd/docs
Browse files Browse the repository at this point in the history
chore: update readme
  • Loading branch information
BramKaashoek committed May 7, 2024
2 parents d0980cd + 5b06f7c commit 8deb29e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-apes-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-loqate": patch
---

update readme
45 changes: 32 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,39 @@ import AddressSearch from 'react-loqate';
<AddressSearch
// ...
components={{
Input: fowardRef((props, ref) => <input {...props} ref={ref} />),
List: forwardRef((props, ref) => {
const { className, ...rest } = props;
// ..
return (
<ul
className={clsx('react-loqate-default-list', className)}
ref={ref}
{...rest}
/>
);
}),
List: forwardRef(({ className, ...rest }, ref) => (
<ul
className={clsx('react-loqate-default-list', className)}
ref={ref}
// ...
{...rest}
/>
)),
ListItem: ({ suggestion, ...rest }) => (
<li
onKeyDown={(e) => {
if (e.key === 'ArrowDown') {
e.preventDefault();
const next = e.target.nextSibling;
if (next) {
next.focus();
}
}
if (e.key === 'ArrowUp') {
e.preventDefault();
const previous = e.taget.previousSibling;
if (previous) {
previous.focus();
}
}
}}
{...rest}
>
`${suggestion.Text} ${suggestion.Description}`
</li>
),
}}
classes={{ listItem: 'styled-list-item' }}
classes={{ Input: classes.input }}
/>;
```

Expand Down

0 comments on commit 8deb29e

Please sign in to comment.