Socket
Socket
Sign inDemoInstall

@peerboard/core

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peerboard/core

peerboard.com frontend components


Version published
Weekly downloads
17
decreased by-10.53%
Maintainers
2
Weekly downloads
 
Created
Source

Usage

See more detailed tutorial in our community

yarn add @peerboard/core 

or

npm install @peerboard/core 
Example integration into react application
// ...
import { createForum } from '@peerboard/core';

class Forum extends React.Component {
  containerRef = React.createRef();
  constructor(props) {
    super(props);
    this.jwtToken = null;
    this.prefix = 'community';
    this.state = {
      authReady: false,
      forumReady: false,
      error: null,
    };
  }

  componentDidMount() {
    http.generateBearerToken((document.location.pathname || "/").replace('/' + this.prefix, '')).then((result) => {
      this.jwtToken = result.token;
      this.setState({
        authReady: true,
      });
      createForum(413170950, this.containerRef.current, {
        prefix: this.prefix,
        jwtToken: this.jwtToken,
        minHeight: "900px",
        onReady: () => {
          this.setState({
            forumReady: true,
          });
        },
        onTitleChanged: (title) => window.document.title = "Community: " + title,
        onPathChanged: (location) => {
          // Browser counts iframe state changes.
          this.props.history.replace(location);
        },
        onCustomProfile: (url) => {
          this.props.history.push(url.replace(window.location.origin, ''));
        },
      }).catch(err => {
        this.setState({
          error: "Failed to load forum",
        });
      });
    })
  }

  renderForum() {
    return <div>
      {!(this.state.authReady && this.state.forumReady) && 'Loading...'}
      <div ref={this.containerRef} style={{
        visibility: this.state.forumReady ? 'visible' : 'hidden',
      }}>
      </div>
    </div>
  }

  render() {
    return (
      <div>
        {this.state.error ? (this.state.error) : (this.renderForum())}
      </div>
    );
  }
}

// ...

Keywords

FAQs

Package last updated on 11 Aug 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc