New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-smart-link-state

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-smart-link-state

A React mixin for linking form fields to a deep structure of data within the component's state.

latest
Source
npmnpm
Version
0.1.7
Version published
Maintainers
1
Created
Source

A React mixin for linking form fields to a deep structure of data within the component's state.

same as react-nest-link-state but more smart;

Installation

$ npm install react-smart-link-state

Example

var SmartLinkedStateMixin = require('react-smart-link-state');
mixins: [SmartLinkedStateMixin],

API

check this file: index.js

getInitialState () {
    return {
        a: [
            {
                b: [1, 2]
            },
            {
                c: [2, 3]
            }
        ]
    }
},
  • nestLinkedState

      let context = this; 
      //default this;you can set parent context to modify parent state  
      
      valueLink={this.nestLinkedState(["a",0,"b",1],context)}  
      //bind to this.state.a[0].b[1]   is 2
      
    
  • nestObject {getValue,setValue,arrSplice,arrPush}

      newState = {this.nestObject(this.state,["a",0,"b",1]).getValue()}  
      // result 2
      
      newState = {this.nestObject(this.state,["a",0,"b",1]).setValue(3)}  
      // return newObject
      
      
          {
              a: [
                  {
                      b: [1, 3]
                  },
                  {
                      c: [2, 3]
                  }
              ]
          }
                  
        newState = {this.nestObject(this.state,["a",0,"b"]).arrSplice(0,2)}  
        // equal array.splice but return hole Object
    
          
              {
                  a: [
                      {
                          b: []
                      },
                      {
                          c: [2, 3]
                      }
                  ]
              }
              
       arrPush is short for   arrSplice   
              
    

Contributing

  • Fork this Repo first
  • Clone your Repo
  • Install dependencies by $ npm install
  • Checkout a feature branch
  • Feel free to add your features
  • Make sure your features are fully tested
  • Publish your local branch, Open a pull request
  • Enjoy hacking <3

MIT license

Copyright (c) 2015 [object Object]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

docor built upon love by docor v0.3.0

Keywords

smart

FAQs

Package last updated on 24 May 2016

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