Home > Blockchain >  How to add a new tree item in a big tree view with a function or action to do this continually? , (M
How to add a new tree item in a big tree view with a function or action to do this continually? , (M

Time:12-26

I need to create a function or do an action that helps to append a new item in the tree view and repeat this action after clicking again in the tree items to add more items in the tree view of MUI

    <TreeView
        aria-label="customized"
        defaultCollapseIcon={<MinusSquare />}
        defaultExpandIcon={<PlusSquare />}
        defaultEndIcon={<CloseSquare />}
      >
        <StyledTreeItem
          nodeId={uuid().toString()}
          label={
            <Typography
              sx={{ color: "green", fontWeight: "bold" }}
              variant="h6"
            >
              {chosenModelName}
            </Typography>
          }
        >
          <StyledTreeItem
            nodeId={uuid().toString()}
            label={<TestSampleDialogue arrayList={AttributesAndRelations} />}
          />
        </StyledTreeItem>
      </TreeView>

I tried to append a new item value and tree item with a dialogue tag from MUIcomponents but it happened one time only appendChild doesn't deal with MUI tags because it doesn't know the name of tags that are different from HTML tags.

CodePudding user response:

try to push your choosen items inside arrayList and map the array as tree items inside your tree view (handle it using useState hook inorder your changes renders).

  • Related