1.0.4 • Published 9 months ago

react-mitt-wrapper v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

react-mitt-wrapper

React provder and hooks for using Mitt events library

NPM JavaScript Style Guide

Install

npm install --save react-mitt-wrapper

Usage

import React, {Component} from 'react'

import {MittProvider, useMittOn} from 'react-mitt-wrapper'

export function App() {
  return <MittProvider>
    <Foo />
  </MittProvider>
}

export function Foo() {
  useMittOn('myEvent', (eventData) => {
    console.log(eventData)
  })

  return <></>
}

Hooks

useMittOn(eventType, callback) – uses for subscribing to the event

useMittOff(eventType, callback) – uses for unsubscribing from the event

useMittEmit() – uses for emitting value to the event. Returns emit function for it

useMittClear() – uses for clearing all events

License

MIT © dkildar

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago