Skip to content

Commit

Permalink
chore: fix docs example
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbach committed Nov 27, 2023
1 parent 5f52497 commit e893e2a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/docs/docs/guides/search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ the `expandSubsequently(path)` function in the [Tree Ref](/docs/api/interfaces/T
Try entering "blackberry" in the example below, and clicking on "Find item":

```jsx live
export const CustomFinder = () => {
function App() {
const [search, setSearch] = useState('');
const tree = useRef(null)

Expand All @@ -140,7 +140,7 @@ export const CustomFinder = () => {
return [item.index];
}
const searchedItems = await Promise.all(
item.children?.map(child => findItemPath(search, child)) ?? []
item.children && item.children.map(child => findItemPath(search, child)) || []
);
const result = searchedItems.find(item => item !== null);
if (!result) {
Expand All @@ -158,10 +158,10 @@ export const CustomFinder = () => {
findItemPath(search).then(path => {
if (path) {
tree.current
?.expandSubsequently(path.slice(0, path.length - 1))
.expandSubsequently(path.slice(0, path.length - 1))
.then(() => {
tree.current?.selectItems([path[path.length - 1]]);
tree.current?.focusItem(path[path.length - 1]);
tree.current.selectItems([path[path.length - 1]]);
tree.current.focusItem(path[path.length - 1]);
});
}
});
Expand All @@ -180,7 +180,7 @@ export const CustomFinder = () => {
/>
<button type="submit">Find item</button>
</form>
<UncontrolledTreeEnvironment<string>
<UncontrolledTreeEnvironment
dataProvider={dataProvider}
getItemTitle={item => item.data}
viewState={{
Expand All @@ -196,5 +196,5 @@ export const CustomFinder = () => {
</UncontrolledTreeEnvironment>
</>
);
};
}
```

0 comments on commit e893e2a

Please sign in to comment.