Skip to content
Open
Changes from all commits
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
28 changes: 18 additions & 10 deletions packages/blade-mcp/knowledgebase/components/TreeView.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,15 @@ function CityPicker() {
import React from 'react';
import { TreeView, TreeViewItem, TreeViewLoadMore } from '@razorpay/blade/components';

// Stubbed data fetchers - replace with your real API calls
const fetchCities = (): Promise<string[]> => Promise.resolve(['Bengaluru', 'Mysuru']);
const fetchMoreCities = (): Promise<string[]> => Promise.resolve(['Hubli', 'Mangaluru']);
Comment thread
rzp-slash-public[bot] marked this conversation as resolved.

function AsyncTree() {
const [cities, setCities] = React.useState<string[]>([]);
const [isLoadingChildren, setIsLoadingChildren] = React.useState(false);
const [isLoadingMore, setIsLoadingMore] = React.useState(false);
const [hasMore, setHasMore] = React.useState(true);

return (
<TreeView selectionType="multiple">
Expand All @@ -318,16 +323,19 @@ function AsyncTree() {
{cities.map((city) => (
<TreeViewItem key={city} title={city} value={city.toLowerCase()} />
))}
<TreeViewLoadMore
isLoading={isLoadingMore}
onClick={() => {
setIsLoadingMore(true);
fetchMoreCities().then((moreCities) => {
setCities((previous) => [...previous, ...moreCities]);
setIsLoadingMore(false);
});
}}
/>
{hasMore && (
<TreeViewLoadMore
isLoading={isLoadingMore}
onClick={() => {
setIsLoadingMore(true);
fetchMoreCities().then((moreCities) => {
setCities((previous) => [...previous, ...moreCities]);
setIsLoadingMore(false);
setHasMore(false);
});
}}
/>
)}
</TreeViewItem>
<TreeViewItem title="Goa" value="goa" />
</TreeView>
Expand Down
Loading