class Simple extends React.Component {
constructor (props) {
super(props)
this.state = {
firstName: 'John',
lastName: 'Rembo'
}
}
render () {
return (<div>
<input {...bindField(this, 'firstName')} />
<input {...bindField(this, 'lastName')} />
</div>)
}
}
const bindField = (context, fieldName) => {
return {
value: context.state[fieldName],
onChange: event => {
const value = event.target.value
context.setState(state => ({ ...state, [fieldName]: value }))
}
}
}
const updateField = (context, fieldName) => value => {
context.setState(state => ({ ...state, [fieldName]: value }))
}
{
"name": "bla_bla_bla",
"version": "0.1.1",
"private": true,
"scripts": {
"start": "webpack-dev-server --mode development",
"build": "NODE_ENV='production' RELEASE='bla_bla_bla@0.1.1' webpack --mode production",
"build:shell": "./build-for-shell.sh",
"test": "react-scripts test --env=jsdom",
"test-coverage": "yarn test --coverage --coverageDirectory=./coverage/",
"ci-test": "CI=true react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint-staged": "lint-staged"
},
"precommit": "lint-staged",
"lint-staged": {
"src/**/*.js": [
"eslint --fix",
"git add"
],
"src/**/*.scss": [
"stylelint --fix --syntax=scss",
"git add"
]
},
когда мы не хотим