Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-component-event

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-component-event

A react component event emit and broadcast tools.

  • 1.1.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-component-event

A React plugin which implemention convenient communication between React components.

Getting Started

Options for adding Less.js to your project:

  • Install with npm: npm install react-component-event
  • Clone the repo: https://github.com/oglen/react-component-event

Usage

  1. require react-component-event to your react component:

     import reactComponentEvent from 'react-component-event';
    
  2. Use reactComponentEvent decorate your component in constructor:

     class Component extends React.Component {
    
         constructor(props) {
             super(props);
             // If this is your root component, set option is {root: true}
             ReactComponentDecorator(this, [option]);
         }
    
         ...
     }
    
  3. And you can use these function in this component easily:

     componentDidMount() {
    
         // Add a event listener to this component
         this.on(EventName, (event, arg) => {
             ...
         });
    
         // Add a event listener only once
         this.once(EventName, (event, arg) => {
             ...
         });
    
         // Dispatch the event to all parent components
         this.emit(EventName, [arg...]);
    
         // Dispatch the event to all children components
         this.broadcast(EventName, [arg...]);
    
         // remove the event listener from this component
         this.off(EventName, [function]);
    
     }
    

Example

There is a clear and concise example in the repo, preview it in following steps:

Enter this project fold and execute:

    npm instasll

    gulp

And visit link:

    http://127.0.0.1:3031/demo/deeptree/

Keywords

FAQs

Package last updated on 06 May 2016

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