I'm using redux-form with material ui autocomplete field.
What I need to do is:
when page load autocomplete value would be empty .
When user start to type and reach to 3 character I want to call API and the result of that API I want to show as autocomplete dataSource.
What I have tried:
I tried to not set dataSource and in seconde try I set dataSource={} in both the case I got same error message:
Failed prop type: The prop
dataSource
is marked as required inAutoComplete
, but its value isundefined
.**
Home.js class code
import React, {Component} from 'react';
import {Field, reduxForm} from 'redux-form';
import AutoComplete from 'material-ui/AutoComplete';
import {connect} from 'react-redux';
class Home extends Component {
renderAutoComplete = ({
input,
label,
meta: {touched, error},
children,
...custom
}) => (
<AutoComplete
floatingLabelText={label}
errorText={touched && error}
{...input}
onChange={(event, index, value) => input.onChange(value)}
children={children}
{...custom}
/>
)
render() {
const startDate = new Date();
const {handleSubmit} = this.props;
return (
<form onSubmit={handleSubmit(this.onSubmit.bind(this))}>
<div>
<Field name="Origin_1" label="FROM" component={this.renderAutoComplete} dataSource={}/>
</div>
<div>
<button type="submit">
Submit
</button>
</div>
</form>
);
}
}
const LogInForm = reduxForm({
form: 'MaterialUiForm', // a unique identifier for this form
validate
})(Home);
export default connect(mapStateTOProps, {getCity})(LogInForm);