Skip to content

Commit e893e2a

Browse files
committed
chore: fix docs example
1 parent 5f52497 commit e893e2a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/docs/docs/guides/search.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ the `expandSubsequently(path)` function in the [Tree Ref](/docs/api/interfaces/T
120120
Try entering "blackberry" in the example below, and clicking on "Find item":
121121

122122
```jsx live
123-
export const CustomFinder = () => {
123+
function App() {
124124
const [search, setSearch] = useState('');
125125
const tree = useRef(null)
126126

@@ -140,7 +140,7 @@ export const CustomFinder = () => {
140140
return [item.index];
141141
}
142142
const searchedItems = await Promise.all(
143-
item.children?.map(child => findItemPath(search, child)) ?? []
143+
item.children && item.children.map(child => findItemPath(search, child)) || []
144144
);
145145
const result = searchedItems.find(item => item !== null);
146146
if (!result) {
@@ -158,10 +158,10 @@ export const CustomFinder = () => {
158158
findItemPath(search).then(path => {
159159
if (path) {
160160
tree.current
161-
?.expandSubsequently(path.slice(0, path.length - 1))
161+
.expandSubsequently(path.slice(0, path.length - 1))
162162
.then(() => {
163-
tree.current?.selectItems([path[path.length - 1]]);
164-
tree.current?.focusItem(path[path.length - 1]);
163+
tree.current.selectItems([path[path.length - 1]]);
164+
tree.current.focusItem(path[path.length - 1]);
165165
});
166166
}
167167
});
@@ -180,7 +180,7 @@ export const CustomFinder = () => {
180180
/>
181181
<button type="submit">Find item</button>
182182
</form>
183-
<UncontrolledTreeEnvironment<string>
183+
<UncontrolledTreeEnvironment
184184
dataProvider={dataProvider}
185185
getItemTitle={item => item.data}
186186
viewState={{
@@ -196,5 +196,5 @@ export const CustomFinder = () => {
196196
</UncontrolledTreeEnvironment>
197197
</>
198198
);
199-
};
199+
}
200200
```

0 commit comments

Comments
 (0)