npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-pigeon

v1.0.0

Published

A little helper spring to call/access methods between react components.

Readme

Pigeon

Postman Pigeon

import React from "react";
import ReactDOM from "react-dom";
import "./Pigeon";   // <---- import after react
import App from "./App";

ReactDOM.render(<App/>,document.querySelector("#root"));

Motivation

The communication is always boring between components, yes there are amazing libraries such as Redux, Mobx even EventBus.

Sometimes you need call a method from a component to another, or sometimes you need to setState from a component to another for a little job.

You have spent your time to setup big amazing libraries 'cause they have actions, reducers, sagas and more.

Please do not confuse, this is not drill down or callback 👻

The main goal is solving your little problem with Pigeon.

How it works?


// ComponentA
// release this pigeon in componentDidMount or useEffect

class ComponentA extends React.Component {
    constructor(props){
        super(props);
        
        release(this);  // <-- You should fly the pigeon ☺️
    }
    
    render(){
      <button onClick={pigeOn('ComponentB.sayHello', {foo: "bar"})}>Fly now!</button>
    }
}

// ComponentB
// You don't need release(this) if you won't call a method from this to another
class ComponentB extends React.Component {
  constructor(props){
    super(props);
  }

  sayHello(data){
      console.log("Hello from ComponentB");
      
      this.setState({myKey: data.foo});
  }
}

Install

  • Npm: npm install pigeon

Rules

  • pigeOn function takes two arguments, first one is required (string);
pigeOn("ComponentName.MethodName", {"your": "data"})
// or
pigeOn("ComponentName.MethodName")
  • Pigeon throws an error if you did not release it when you call pigeOn

  • If you release pigeon many times, you will see a warning in console like;

    The Component is already in cage.

Example Scene

You can see it in action with this demo

import React from "react";
import './style.css';

class Component1 extends React.Component {
  constructor(props) {
    super(props);
    release(this);
  }

  sendData = () => {
    pigeOn('Component2.changeNumber', {count: 19});
    pigeOn('Component3.changeMyColor', {newColor: '#cc9200'});
    pigeOn('Component4.introduceYourself');
    pigeOn('Component4.anotherMethod');
  }

  render(){
    return (
            <div style={{background: '#f4f4f4', padding: 20}}>
              <h1>Component1</h1>
              <button onClick={() => this.sendData()}>Fly Pigeon to Component2, Component3 and Component4</button>
            </div>
    )
  }
}

class Component2 extends React.Component {
  constructor(props) {
    super(props);
    release(this);

    this.state = {
      number: 1
    }
  }

  changeNumber(e){
    this.setState({number: e.count})
  }

  render(){
    return (
            <div style={{background: '#e1e1e1', padding: 20}}>
              <h1>Component2</h1>
              <p>The secret number : <label>{this.state.number}</label></p>
            </div>
    )
  }
}

class Component3 extends React.Component {
  constructor(props) {
    super(props);
    release(this);

    this.state = {
      bg: '#2984fa'
    }
  }

  componentDidMount() {
    release(this)
  }

  changeMyColor(e){
    console.log("Component3");
    this.setState({bg: e.newColor})
  }

  render(){
    return (
            <div style={{background: this.state.bg, padding: 20}}>
              <h1>Component3</h1>
              <p>My background can be change by a pigeon from Component1</p>
            </div>
    )
  }
}

class Component4 extends React.Component {
  constructor(props) {
    super(props);
    release(this);
  }

  introduceYourself(e){
    alert("I'm component 4")
  }

  anotherMethod() {
    alert("They come in order, please stop work with me!")
  }

  render() {
    return (
            <div style={{padding: 20}}>
              <h1>Component4</h1>
              <button onClick={() => pigeOn('Component2.changeNumber', {count: 2021}) }>I want to change number from Component2</button>
            </div>
    )
  }
}


const App = () => (
        <div>
          <Component1/>
          <hr/>
          <br/>
          <Component2/>
          <hr/>
          <br/>
          <Component3/>
          <hr/>
          <br/>
          <Component4/>
        </div>
);


export default App;