MCPcopy Create free account
hub / github.com/adobe/react-spectrum / load

Function load

examples/s2-parcel-example/src/components/CardViewExample.jsx:103–116  ·  view source on GitHub ↗
({signal, cursor, items})

Source from the content-addressed store, hash-verified

101export const CardViewExample = props => {
102 let list = useAsyncList({
103 async load({signal, cursor, items}) {
104 let page = cursor || 1;
105 let res = await fetch(
106 `https://api.unsplash.com/topics/nature/photos?page=${page}&per_page=30&client_id=AJuU-FPh11hn7RuumUllp4ppT8kgiLS7LtOHp_sp4nc`,
107 {signal}
108 );
109 let nextItems = await res.json();
110 // Filter duplicates which might be returned by the API.
111 let existingKeys = new Set(items.map(i => i.id));
112 nextItems = nextItems.filter(
113 i => !existingKeys.has(i.id) && (i.description || i.alt_description)
114 );
115 return {items: nextItems, cursor: nextItems.length ? page + 1 : null};
116 }
117 });
118
119 let loadingState = props.loadingState === 'idle' ? list.loadingState : props.loadingState;

Callers

nothing calls this directly

Calls 2

filterMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected