react-state-eventer

1.0.2 • Public • Published

react-state-eventer

Event emitter for React state

Build Status

Overview

A very simple alternative to Redux

Demo

Live Demo

npm run demo

Browse the code for the demo app here.

Example

import StateEventer from 'state-eventer'
import reactStateEventer from 'react-state-eventer'

const state = new StateEventer()
const withStateEventer = reactStateEventer(state)

function increment() {
  const count = state.get('count') || 0
  state.set('count', count + 1)
}

const MyComponent = ({ count }) => (
  <button onClick={increment}>
    Increment: {count}
  </button>
)

const getProps = (state, props) => ({
  count: state.get('count')
}

const myComponent = withStateEventer(getProps)(MyComponent)

Tests

npm test

Readme

Keywords

none

Package Sidebar

Install

npm i react-state-eventer

Weekly Downloads

8

Version

1.0.2

License

MIT

Unpacked Size

1.55 MB

Total Files

13

Last publish

Collaborators

  • will123195