Answer the question
In order to leave comments, you need to log in
What is the cause of error when controlling on input React?
Actually the essence:
if I write immediately in the function that I call (as in the code below)
this.setState({
value: event.target.value
})
the react is silent about errors.
if I do, essentially the same thing, but already in if, then in the console a message like this
enterToThisState(event){
this.setState({
value: event.target.value
})
let empty;
let value = event.target.value;
if (value.length == 0){
empty = true;
this.setState({
error_emty_field: 'formError',
empty: true,
})
} else {
empty = false;
this.setState({
error_emty_field: '',
empty: false,
})
}
this.props.data_from_required({
empty: empty,
value: event.target.value,
name: event.target.name,
}, event)
}
return <input
name = {data.name}
type = {data.type}
defaultValue = {data.value}
value = {this.state.value}
className = {data.className + this.state.error_emty_field}
placeholder = {data.placeholder}
onChange = {data.onChange}
onChange={this.enterToThisState.bind(this)} />
export default connect(
state => ({
login: state.authorizationR.login,
token: state.authorizationR.token,
user_permission: state.authorizationR.user_permission,
ThisTransport: state.devicesR.ThisTransport,
}),
dispatch => bindActionCreators(ActionCreator, dispatch)
)(TransportPage)
const actionCreators = {
getData : getData,
};
export default actionCreators
store.dispatch({
type: 'GET_devices',
[dispatch_key]: newlist
})
export default function configureStore(initialState) {
const store = createStore(rootReducer, initialState)
return store
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question