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

Function load

examples/s2-next-macros/src/app/components/CardViewExample.jsx:104–117  ·  view source on GitHub ↗
({signal, cursor, items})

Source from the content-addressed store, hash-verified

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