Changeset 2998dc4 for reactapp/src/Components
- Timestamp:
- 07/30/22 15:39:04 (2 years ago)
- Branches:
- main
- Children:
- e958037
- Parents:
- 3a44163
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
reactapp/src/Components/OpinionTree.js
r3a44163 r2998dc4 1 1 function OpinionTree({ professor }) { 2 function displayChildPosts(post) { 3 if (post == null) return; 2 var renderedOpinionIds = []; 3 var postCount; // za da ne go pokazuva ispod postot 4 5 function displayChildPosts(child) { 6 if (child == null) return; 7 postCount = renderedOpinionIds.push(child.postId); 4 8 return ( 5 <div key={post.postId}> 6 <p>Содржина: {post.content}</p> 7 {post.children.map((child) => displayChildPosts(child))} 9 <div key={child.postId}> 10 <p>{child.author.username} реплицирал</p> 11 <p>Содржина: {child.content}</p> 12 {child.children.map((childOfChild) => displayChildPosts(childOfChild))} 8 13 </div> 9 14 ); … … 13 18 <div className="opinionTree"> 14 19 {professor.relatedOpinions.map((opinion) => { 15 if (opinion.hasOwnProperty("title")) { 20 if (!renderedOpinionIds.includes(opinion.postId)) { 21 postCount = renderedOpinionIds.push(opinion.postId); 16 22 return ( 17 23 <div key={opinion.postId}> 24 <p>{opinion.author.username} напишал</p> 18 25 <p>Наслов: {opinion.title}</p> 19 26 <p>Содржина: {opinion.content}</p> 20 27 {opinion.children.map((child) => displayChildPosts(child))} 28 <hr /> 21 29 </div> 22 30 );
Note:
See TracChangeset
for help on using the changeset viewer.