# react-app-events

> Use global events in your React app with hooks

Latest version **2.0.2** (published 2023-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-app-events
pnpm add react-app-events
yarn add react-app-events
bun add react-app-events
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2023-04-02 |
| First published | 2020-01-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | nicolaslopezj |
| Maintainers | nicolaslopezj |

## Links

- npm: https://www.npmjs.com/package/react-app-events
- Repository: https://github.com/nicolaslopezj/react-app-events
- npm.io page: https://npm.io/package/react-app-events

## Recent versions

- 2.0.2 (latest) — 2023-04-02
- 2.0.1 — 2023-03-29
- 2.0.0 — 2021-12-24
- 1.0.0 — 2020-01-20

## README

# React App Events

Use global events in your React app with hooks

## Install the package

```
yarn add react-app-events
```

No extra setup is needed


## Listen for events

We use a hook for event listener.

```jsx
import React from 'react'
import useOnEvent from 'react-app-events/lib/useOnEvent'

export default function ComponentA(props) {
  useOnEvent('buttonClicked', data => {
    console.log(data)
  })
  return <div>Hello world</div>
}
```

## Fire events

```jsx
import React from 'react'
import fireEvent from 'react-app-events/lib/fireEvent'

export default function ComponentB(props) {
  return (
    <div>
      <button
        onClick={event => {
          fireEvent('buttonClicked', event)
        }}>
        Click me
      </button>
    </div>
  )
}
```

---
_Source: https://npm.io/package/react-app-events · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
