Ignore:
Timestamp:
07/30/22 15:39:04 (2 years ago)
Author:
unknown <mlviktor23@…>
Branches:
main
Children:
e958037
Parents:
3a44163
Message:

made OpinionTree display author info

File:
1 edited

Legend:

Unmodified
Added
Removed
  • reactapp/src/Components/OpinionTree.js

    r3a44163 r2998dc4  
    11function 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);
    48    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))}
    813      </div>
    914    );
     
    1318    <div className="opinionTree">
    1419      {professor.relatedOpinions.map((opinion) => {
    15         if (opinion.hasOwnProperty("title")) {
     20        if (!renderedOpinionIds.includes(opinion.postId)) {
     21          postCount = renderedOpinionIds.push(opinion.postId);
    1622          return (
    1723            <div key={opinion.postId}>
     24              <p>{opinion.author.username} напишал</p>
    1825              <p>Наслов: {opinion.title}</p>
    1926              <p>Содржина: {opinion.content}</p>
    2027              {opinion.children.map((child) => displayChildPosts(child))}
     28              <hr />
    2129            </div>
    2230          );
Note: See TracChangeset for help on using the changeset viewer.