V
V
vaskadogana2017-04-04 10:16:31
React
vaskadogana, 2017-04-04 10:16:31

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
input_error.jpg

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)
  }

the input itself
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)} />

Why I ask, it is interesting to understand the mechanism of work.
And one more question, now you have to write to the storage only according to the scheme below, and this is everywhere to declare the store, getState (). The example is described through return, but my react ignores the entry. I suspect that due to what I do through the actionCreator or I'm stupid (I couldn't google anything)
connecting to the component
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)

actionCreators itself
const actionCreators = { 
      getData : getData,
};
  export default actionCreators

storage entry
store.dispatch({
        		type: 'GET_devices',
        		[dispatch_key]: newlist
      })

store config
export default function configureStore(initialState) {
  const store = createStore(rootReducer, initialState)
  return store
}

I would be grateful for comments, I looked at the compiled file, there are more than 60 store ads ... I don’t like this scheme

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question