Skip to content

Commit 6907e1e

Browse files
committed
making the async stories not load forever
1 parent 81de58a commit 6907e1e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/react-aria-components/stories/Tree.stories.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ function MultiLoaderTreeMockAsync(args) {
722722
let [isDocumentsLoading, setDocumentsLoading] = useState(false);
723723

724724
let onRootLoadMore = useCallback(() => {
725-
if (!isRootLoading) {
725+
if (!isRootLoading && rootData.items.length < 30) {
726726
action('root loading')();
727727
setRootLoading(true);
728728
setTimeout(() => {
@@ -738,7 +738,7 @@ function MultiLoaderTreeMockAsync(args) {
738738
}, [isRootLoading, rootData, args.delay]);
739739

740740
let onProjectsLoadMore = useCallback(() => {
741-
if (!isProjectsLoading) {
741+
if (!isProjectsLoading && projectsData.items.length < 30) {
742742
action('projects loading')();
743743
setProjectsLoading(true);
744744
setTimeout(() => {
@@ -754,7 +754,7 @@ function MultiLoaderTreeMockAsync(args) {
754754
}, [isProjectsLoading, projectsData, args.delay]);
755755

756756
let onProjectsLevel3LoadMore = useCallback(() => {
757-
if (!isProjectsLevel3Loading) {
757+
if (!isProjectsLevel3Loading && projects3Data.items.length < 30) {
758758
action('projects level 3 loading')();
759759
setProjects3Loading(true);
760760
setTimeout(() => {
@@ -770,7 +770,7 @@ function MultiLoaderTreeMockAsync(args) {
770770
}, [isProjectsLevel3Loading, projects3Data, args.delay]);
771771

772772
let onDocumentsLoadMore = useCallback(() => {
773-
if (!isDocumentsLoading) {
773+
if (!isDocumentsLoading && documentsData.items.length < 30) {
774774
action('documents loading')();
775775
setDocumentsLoading(true);
776776
setTimeout(() => {
@@ -797,7 +797,6 @@ function MultiLoaderTreeMockAsync(args) {
797797
if (item.id === 'projects') {
798798
return (
799799
<StaticTreeItem id="projects" textValue="Projects" title="Projects">
800-
801800
<Collection items={projectsData.items}>
802801
{(item: any) => {
803802
return item.id !== 'projects-1' ?

0 commit comments

Comments
 (0)