-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1846 from dev-launchers/development/ideaspace
Development/ideaspace
- Loading branch information
Showing
6 changed files
with
124 additions
and
114 deletions.
There are no files selected for viewing
This file contains 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
38 changes: 26 additions & 12 deletions
38
apps/ideaspace/src/components/modules/WorkshoppingPage/CommentsForm/DisplayComments.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import React, { useState } from 'react'; | ||
import Comment from './SingleComment'; | ||
import { cleanDataList } from '../../../../utils/StrapiHelper'; | ||
import axios from 'axios'; | ||
|
||
//create your forceUpdate hook | ||
function useForceUpdate() { | ||
const [value, setValue] = useState(0); // integer state | ||
return () => setValue(value => value + 1); // update state to force render | ||
// A function that increment 👆🏻 the previous state like here | ||
return () => setValue((value) => value + 1); // update state to force render | ||
// A function that increment 👆🏻 the previous state like here | ||
// is better than directly setting `setValue(value + 1)` | ||
} | ||
|
||
function DisplayComments(props) { | ||
const commentNodes = props.comments.map(comment => { | ||
return <Comment author={comment.author} key={comment.id} id={comment.id} createdAt={comment.createdAt} publishedAt={comment.publishedAt} updatedAt={comment.updatedAt} forIdea={props.selectedCard}> | ||
{comment.text} | ||
</Comment> | ||
const commentNodes = props.comments.map((comment) => { | ||
const commentUser = comment.user; | ||
return ( | ||
<Comment | ||
user={commentUser} | ||
author={commentUser.profile.displayName} | ||
key={comment.id} | ||
id={comment.id} | ||
createdAt={comment.createdAt} | ||
publishedAt={comment.publishedAt} | ||
updatedAt={comment.updatedAt} | ||
forIdea={props.selectedCard} | ||
> | ||
{comment.text} | ||
</Comment> | ||
); | ||
}); | ||
|
||
return ( | ||
<div> | ||
{props.comments.length ? commentNodes : <div style={{ padding: "2rem" }}>No comments yet!</div>} | ||
{props.comments.length ? ( | ||
commentNodes | ||
) : ( | ||
<div style={{ padding: '2rem' }}>No comments yet!</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
} | ||
|
||
export default DisplayComments; | ||
export default DisplayComments; |
This file contains 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
This file contains 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
Oops, something went wrong.