Created
July 10, 2020 15:21
-
-
Save leonidkuznetsov18/173abff5e51153bd42d7f2a45edcde03 to your computer and use it in GitHub Desktop.
recursive rendering tree in react
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Tree = ({ data }) => { | |
| return data?.map((p: NumberingBranch) => { | |
| return ( | |
| <div key={p.id} className="NumberingList__Parent"> | |
| <div> | |
| <div className="NumberingList__ItemWrapper"> | |
| <span className="NumberingList__Title">{p.data.text}</span> | |
| </div> | |
| </div> | |
| {p.children.length > 0 && <Tree data={p.children} />} | |
| </div> | |
| ); | |
| }); | |
| }; | |
| const renderNumberingTree = (data) => { | |
| return ( | |
| <div className="NumberingScreen"> | |
| <div className="NumberingList">{<Tree treeData={data} />}</div> | |
| </div> | |
| ); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment