npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

react-linkstate-decorator

0.0.4 • Public • Published

Build Status Code Climate Test Coverage Dependency Status devDependency Status

react-linkstate-decorator

Enables two way binding on decorated components via linkState and valueLink.

Installation

Run <npm install --save react-linkstate-decorator> and then use the default export of the module.

Purpose

This will allow two way data flow between decorated components via linkState and valueLink. This will assign a createlinkState method to the component's linkState attribute for easy use. For more information about linkState and the valueLink property, please visit https://facebook.github.io/react/docs/two-way-binding-helpers.html.

Example

Using the decorator, you can enable a two way binding via valueLink and linkState between a parent and child component.

import LinkState from 'react-linkstate-decorator';
 
class ChildComponent extends Component {
  render() {
    return (
      <div>{this.props.valueLink.value}</div>
    );
  }
}
 
@LinkState
class ParentComponent extends Component {
  constructor() {
    super();
    this.state = {
      val: 1
    };
  }
 
  render() {
    return (
      <ChildComponent valueLink={this.linkState('val')}/>
    );
  }
}

Keywords

none

install

npm i react-linkstate-decorator

Downloadsweekly downloads

1

version

0.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability