Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
131 views
in Technique[技术] by (71.8m points)

javascript - How to create nested child components dynamically in react?

I know how to dynamically render components based on state and conditional rendering, yet what I'm trying to do is rendering an unclear number of components, inside each other, dynamically.

I have a tree component that maps through an array for the first level of data, yet nested levels are lazy-loaded (by clicking on them, there is a request to the server to fetch the children of that node). I can hard code some more tree components nested for the next few levels of nesting, But what if there was an infinite number of children nested in children. I want them to be dynamically created (something like js appendchild, by clicking on that node), yet in the standard react way.

<Tree>
    <TreeItem>             //first level
         <TreeItem>        // second level
               ...        // infinit levels, each level generate by clicking on parent
         </TreeItem>
    </TreeItem>
</Tree>
question from:https://stackoverflow.com/questions/65949464/how-to-create-nested-child-components-dynamically-in-react

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...