
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
react-discussion-board
Advanced tools
This component creates a simple React Discussion Board. Posts include profile image, message, name, and date/time. New posts may be added and edited in Rich Text formatting.
Table of Contents generated with DocToc
This module is distributed via [npm][npm] which is bundled with [node][node] and should be installed as one of your project's dependencies
:
npm install react-discussion-board
This package also depends on
react
. Please make sure you have it installed as well.
import React, { useState } from 'react'
import DiscussionBoard from 'react-discussion-board'
import 'react-discussion-board/dist/index.css'
const App = () => {
const allPosts = [
{
profileImage:
'https://www.rd.com/wp-content/uploads/2017/09/01-shutterstock_476340928-Irina-Bg.jpg,
name: 'Jane Doe',
content: '<p>Hello everyone!</p><p>How are you all doing?</p><p>-Jane</>',
date: new Date('01 Jan 2020 01:12:00 GMT')
},
{
profileImage:
'https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500',
name: 'John Doe',
content:
'<p>Raising say express had chiefly detract demands she. Quiet led own cause three him. Front no party young abode state up. Saved he do fruit woody of to. Met defective are allowance two perceived listening consulted contained. It chicken oh colonel pressed excited suppose to shortly. He improve started no we manners however effects. Prospect humoured mistress to by proposal marianne attended. Simplicity the far admiration preference everything. Up help home head spot an he room in Barton waited twenty always repair in within we do. An delighted offending curiosity my is dashwoods at. Boy prosperous increasing surrounded companions her nor advantages sufficient put. John on time down give meet help as of. Him waiting and correct believe now cottage she another. Vexed six shy yet along learn maids her tiled. Through studied shyness evening bed him winding present. Become excuse hardly on my thirty it wanted. </p>',
date: new Date('01 Jan 2020 09:12:00 GMT')
}
]
const [posts, setPosts] = useState(allPosts)
const submitPost = (text) => {
const curDate = new Date()
setPosts([
...posts,
{
profileImage:
'https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500',
name: 'Jane Doe',
content: text,
date: curDate
}
])
}
return (
<div className='App'>
<DiscussionBoard posts={posts} onSubmit={submitPost} />
</div>
)
}
export default App
DiscussionBoard
is the only component exposed by this package.
<DiscussionBoard posts={posts} onSubmit={onSubmit}>
This is the list of props.
array
| defaults to[]
Pass an array of posts that should be available in discussion board.
Content is sanitized before being displayed on the page as a post.
Following are the fields that may be provided for posts in the posts
prop array
Field | Type | Description |
---|---|---|
profileImage | string | image url/path for profile photo |
name | string | display name of post author |
content | string | content string in rich text format (html string) |
date | Date | post date |
function(text: string)
| required
Function that is called when a post is submitted, given the html text of the post.
FAQs
Discussion board for creating forums in React
The npm package react-discussion-board receives a total of 0 weekly downloads. As such, react-discussion-board popularity was classified as not popular.
We found that react-discussion-board demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.