3.0.1 • Published 7 years ago

barracks-react v3.0.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
7 years ago

barracks-react

An action dispatcher for React that provides for unidirectional dataflows. Intended to be very small and provide a small amount of cognative overhead in providing an "actions up, data down" type model for React. Built on top of barracks.

Usage

const React = require('react')
const ReactDOM = require('react-dom')
const bearact = require('./')

const model = {
  namespace: 'example',
  state: {
    hello: ''
  },
  reducers: {
    setHello: (state, data) => ({hello: data.value})
  }
}

const Main = React.createClass({
  handleChange: function (evt) {
    this.props.send('setHello', {value: evt.target.value})
  },
  render: function () {
    return React.createElement('div', {}, [
      React.createElement('h1', {}, `Hello, ${this.props.model.hello}`),
      React.createElement('br', {}, null),
      React.createElement('input', {value: this.props.model.hello, onChange: (evt) => this.handleChange(evt)}, null)])
  }
})

const main = React.createElement(bearact(Main, model))
const mount = document.createElement('div')
document.body.appendChild(mount)
ReactDOM.render(main, mount)

License

Copyright © 2016 Scripto, licenced under the Apache-2.0 license

3.0.1

7 years ago

3.0.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago