rls

react-lensed-state

React mixin, for this.linkState ('model.user.name')

Showing:

Popularity

Downloads/wk

3

GitHub Stars

9

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Build Status NPM version Dependencies Status experimental

react-lensed-state

Adds react opportunity to work with the state in a hierarchical notation, for example this.linkState ('model.user.name') will point to the part of the object state. Work of lens are immutable, that is, after changing the value will create a new state object.

Example

var LensedExample = React.createClass({
  
      mixins : [LensedStateMixin],
 
      getInitialState : {
          model : {
              user : {
                  name: "John",
                  email: "john@example.com"
              },
              notify : {
                  email : true,
                  fb: false
              }
          }
      },
 
      render: function() {
          return (
              <form>
                  <input valueLink={this.linkState('model.user.name')} type="text" name="user-name" />
                  <input valueLink={this.linkState('model.user.email')} type="text" name="user-email" />
                  <input valueLink={this.linkState('model.notify.email')} type="checkbox" name="notify-email" />
                  <input valueLink={this.linkState('model.notify.fb')} type="checkbox" name="notify-fb" />
             </form>
          );
      }
  });

Installing

The easiest way is to grab it from NPM. If you're running in a Browser environment, you can use [Browserify][]

$ npm install react-lensed-state

NPM

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial