Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

barracks-react

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barracks-react

An action dispatcher for unidirectional data flows for React components

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

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

Keywords

FAQs

Package last updated on 12 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc