source: reactapp/src/Components/OpinionTree.js@ 3a44163

main
Last change on this file since 3a44163 was 3a44163, checked in by unknown <mlviktor23@…>, 2 years ago

created OpinionTree component

  • Property mode set to 100644
File size: 769 bytes
Line 
1function OpinionTree({ professor }) {
2 function displayChildPosts(post) {
3 if (post == null) return;
4 return (
5 <div key={post.postId}>
6 <p>Содржина: {post.content}</p>
7 {post.children.map((child) => displayChildPosts(child))}
8 </div>
9 );
10 }
11
12 return (
13 <div className="opinionTree">
14 {professor.relatedOpinions.map((opinion) => {
15 if (opinion.hasOwnProperty("title")) {
16 return (
17 <div key={opinion.postId}>
18 <p>Наслов: {opinion.title}</p>
19 <p>Содржина: {opinion.content}</p>
20 {opinion.children.map((child) => displayChildPosts(child))}
21 </div>
22 );
23 }
24 })}
25 </div>
26 );
27}
28
29export default OpinionTree;
Note: See TracBrowser for help on using the repository browser.