Skip to content

ListView and useAsyncList fails with TypeError: Cannot read properties of undefined (reading 'key') #6074

@synox

Description

@synox

Provide a general summary of the issue here

When using AsyncListData with ListView, and setting the ListView.height=100%, and I scroll quickly down and up, I get the following error:

TypeError: Cannot read properties of undefined (reading 'key')
    at $4e8b0456ef72939f$export$9610e69494fadfd2 (https://.../vendors-node_modules_..._esm_index_js-node_modules_...-fd91c693251bcbbc8d02113289.js:125258:19)
Screen.Recording.2024-03-18.at.18.01.19.mov

🤔 Expected Behavior?

It should not show an error

😯 Current Behavior

It shows an error on scroll.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

reproduce in react-spectrum-v3-playground:

function Component() {
  const list = useAsyncList({
    async load({ cursor, filterText, signal }) {
      const res = await fetch(cursor || 'https://pokeapi.co/api/v2/pokemon?limit=10', {
        signal,
      });
      const json = await res.json();
      return {
        items: json.results,
        cursor: json.next,  
      };
    },
  });

  return (
    <View>
      <ListView height="300px"
        items={list.items}
        loadingState={list.loadingState}
        onLoadMore={list.loadMore}
      >
        {(item) => {
          return <Item key={item.name}>{item.name}</Item>;
        }}
      </ListView>
    </View>
  );
}

Version

3.33.2

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macos

🧢 Your Company/Team

Adobe AEM

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions