1.0.2 • Published 4 years ago

react-state-eventer v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

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
1.0.2

4 years ago

1.0.1

4 years ago