Closed
Description
❔ Question
I've been trying to create a listbox-based component with async loading & infinite content using useAsyncList,
As it was not working as expected, I went to the basic and tried the code sample based on the (see below).
However, once the initial entries have been displayed, scrolling at the end of the picker's list doesn't load more items.
Is it supposed to work?
Thanks!
🔦 Context
💻 Code Sample
import './App.css';
import { Provider, defaultTheme, Picker, Item, useAsyncList, View } from '@adobe/react-spectrum';
function App() {
let list = useAsyncList({
async load({signal, cursor}) {
console.log('loading', cursor);
// If no cursor is available, then we're loading the first page.
// Otherwise, the cursor is the next URL to load, as returned from the previous page.
let res = await fetch(cursor || 'https://pokeapi.co/api/v2/pokemon', {
signal
});
let json = await res.json();
return {
items: json.results,
cursor: json.next
};
}
});
return (
<Provider theme={defaultTheme}>
<View borderWidth="thin" borderColor="dark" padding="size-200">
<Picker label="Select a pokemon" items={list.items} isLoading={list.isLoading} onLoadMore={list.onLoadMore}>
{(item) => <Item key={item.name}>{item.name}</Item>}
</Picker>
</View>
</Provider>
);
}
export default App;
🌍 Your Environment
Software | Version(s) |
---|---|
react-spectrum | 3.7.0 |
Browser | Edge 87.0.664.75 |
Operating System | Windows 10 |
🧢 Your Company/Team
Metadata
Metadata
Assignees
Labels
No labels