New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-broadcastchannel

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-broadcastchannel

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/BasixKOR/react-broadcastchannel/CI?style=flat-square) ![npm bundle size](https://img.shields.io/bundlephobia/min/react-broadcastchannel?style=flat-square) ![npm](https://img.shields.i

latest
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

react-broadcastchannel

GitHub Workflow Status npm bundle size npm

This library gives you a simple hook useBroadcastChannel to post or receive message from/to channels.

import * as React from 'react';
import { useBroadcastChannel } from 'react-broadcastchannel';

const App = () => {
  const [count, setCount] = React.useState(0);
  const [post] = useBroadcastChannel<number>('counter', ev => setCount(ev.data))

  const handler = () => {
    post(count + 1);
    setCount(count => count + 1);
  }

  return (
    <div>
      <button onClick={handler}>
        {count}
      </button>
    </div>
  );
};

What is BroadcastChannel API?

BroadcastChannel API allows to communicate between browsing contexts such as iframes, browser tabs, or even workers on the same origin.

API

useBroadcastChannel

const [post] = useBroadcastChannel<Message>('channel-id', event => event.data)

FAQs

Package last updated on 10 Sep 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