2.1.0 • Published 6 years ago
react-model-controller v2.1.0
React Model
An easy way to implement two-way data binding in React without using mixins. Tired of defining handleChange() functions? Here's solution, react-model-controller.
npm i react-model-controller
Usage:
import ModelController from 'react-model-controller'
constructor (props) {
...
this.models = {
name: ModelController.create({
target: this,
name: 'name'
})
}
...
}
render () {
...
<input
value={this.models.name.get()}
onChange={this.models.name.set()}
>
...
}
or
<input {...ModelController.link(this, 'name')}>
API
public static ReactModelController.create()
Argument | Type | |
---|---|---|
target | React.Component | A react component, which state should be updated, when input value changes. Most of the time it will be |
name | String | A name for state prop to change. |
defaultValue | Any | Default value to state. |
validate | Function | Function |
mask | String | An input mask. Example: "** ** ** **" |
Returns a new ReactModelController instance.
Changelog
v2.0
- Added automating input masking.
- Added ReactModelController.create() static method
- Added .link public property
2.1.0
6 years ago
2.0.5
6 years ago
2.0.4
6 years ago
2.0.3
6 years ago
2.0.2
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.7.0
6 years ago
1.6.0
6 years ago
1.5.2
6 years ago
1.5.1
6 years ago
1.5.0
6 years ago
1.4.2
6 years ago
1.4.1
6 years ago
1.4.0
6 years ago
1.3.0
6 years ago
1.2.1
6 years ago
1.2.0
6 years ago
1.1.0
6 years ago
1.0.0
6 years ago
0.2.0
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago