dgreene1 / react-accessible-treeview

A react component that implements the treeview pattern as described by the WAI-ARIA Authoring Practices.
https://dgreene1.github.io/react-accessible-treeview
MIT License
277 stars 37 forks source link

Error "Cannot read properties of undefined (reading 'id')" with Asynchronous Loading after Re-rendering compoent #161

Closed ui-jenny-hong closed 9 months ago

ui-jenny-hong commented 1 year ago

Describe the bug I encountered an issue when using asynchronous loading with react-accessible-treeview. After initially loading child data by clicking on a parent node, if I hide the component and then display it again, clicking on the same parent node to fetch child data results in an error: "Cannot read properties of undefined (reading 'id')".

Example Code:

Here is a CodeSandbox link that reproduces the issue.

To Reproduce Steps to reproduce the behavior:

  1. Load the provided example.
  2. Click on a parent node to trigger onLoadData and fetch child data.
  3. Click on the "display" button to hide the component.
  4. Click the "display" button again to show the component.
  5. Click on the same parent node as in step 2.
  6. The error "Cannot read properties of undefined (reading 'id')" is thrown.

Expected behavior After re-displaying the component, I should be able to click on any parent node and load child data without any errors.

Screenshots

截圖 2023-10-29 下午9 42 28
dgreene1 commented 1 year ago

@ui-jenny-hong, I can’t tell from the example if the issue is in the library or in the calling code. But if you’re willing to make a PR, we’ll accept it. We’d want to make sure that the bug can be reproduced in our unit testing code.

stale[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 9 months ago

This issue was closed automatically since it was marked as stale because it has not had recent activity. Thank you for your contributions.