Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
babel-plugin-react-binding
Advanced tools
Two way binding sugar for React.
npm i babel-plugin-react-binding --save-dev
react-binding
to .babelrc
{
"plugins": [
["react-binding", {
// options
}]
]
}
<div>
<input binding={this.state.inputValue}>
<Dialog binding={this.state.dialogOpen}>
</div>
class App extends React.Component {
render () {
return (
<input id='input' binding={this.props.input} />
)
}
}
export default connect(
state => state.form,
dispatch => ({
onChange (value, key) {
dispatch({
type: 'UPDATE_FORM',
key,
value,
})
},
})
)(App)
react-binding
will automatically add value
and onChange
props to React Element. After the event triggered, react-binding
will receive the new value, and execute setState()
to update the value.
You can think of it as (if you write by hand):
<input
value={this.state.inputValue}
onChange={e => this.setState({ inputValue: e.target.value })}
>
Use babel option to custom the prop name (default binding
)
{
"plugins": [
["react-binding", {
"attrName": "bindModel"
}]
]
}
Then the jsx code may be like:
<input bindModel={this.state.inputValue}>
By default, react-binding
use value
and onChange
as default prop names for two-way binding (except radio and checkbox, they use checked
). But some custom component may use another prop name, for example onInput
.
Use static property bindingDescriptor
for adaptation.
CustomComponent.bindingDescriptor = {
prop: 'number',
event: 'onInput',
}
FAQs
babel plugin for React two-way bind
The npm package babel-plugin-react-binding receives a total of 13 weekly downloads. As such, babel-plugin-react-binding popularity was classified as not popular.
We found that babel-plugin-react-binding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.