2017-06-21 4 views
0

Ich versuche, eine Autovervollständigung für die Redux-Form mit Redux-Form-Material-UI zu erstellen. Jedoch bin ich mit diesem Problem fest, dass der onUpdateInput nicht feuert. hier ist ein Teil meines Code, um das AutocompleteOnUpdateInput wird nicht auf Redux-Formular Material ui gefeuert?

import { Field, reduxForm } from 'redux-form'; 
import { DatePicker, AutoComplete } from 'redux-form-material-ui'; 
class autocompleteComponent extends React.Component { 

    onChange = value => { 
     //this is firing properly 
    } 

    onSearch = value => { 
    //this is not firing at all 
    const { getPatients } = this.props; 
    if (value.length) { 
     getPatients(value); 
    } 
    } 

    render() { 
     const { patientData} = this.props; 
     return (
      <Field 
       id="patient-no" 
       name="patientNo" 
       hintText="Patient No" 
       component={AutoComplete} 
       dataSource={patientData} 
       dataSourceConfig={{ text: 'patientNo', value: 'patientNo' }} 
       onNewRequest={value => this.onChange(value)} 
       onUpdateInput={value => this.onSearch(value)} 
       filter={(searchText, key) => true} 
       fullWidth={true} /> 
    ) 
    } 
} 

Zusammenhang Wenn jemand mir helfen konnte oder einige Hinweise zu diesem Thema hat, mich bitte nicht wissen lassen.

dank

Antwort

0

Sie können diese

import { Field, reduxForm } from 'redux-form'; 
import { DatePicker, AutoComplete } from 'redux-form-material-ui'; 
class autocompleteComponent extends React.Component { 

    onChange(value) { 
    //this is firing properly 
    } 

    onSearch(value) { 
    const { getPatients } = this.props; 
    if(value.length) { 
     getPatients(value); 
    } 
    } 

    render() { 
     const { patientData} = this.props; 
     return (
      <Field 
       id="patient-no" 
       name="patientNo" 
       hintText="Patient No" 
       component={AutoComplete} 
       dataSource={patientData} 
       dataSourceConfig={{ text: 'patientNo', value: 'patientNo' }} 
       onNewRequest={value => this.onChange(value)} 
       onUpdateInput={this.onSearch.bind(this)} //no need to pass any value 
       filter={(searchText, key) => true} 
       fullWidth={true} /> 
    ) 
    } 
} 
Versuchen
Verwandte Themen