I'm using react-autosuggest for make a autocomplete input (fetch on type). My code is based on AutoCompleteArrayInput
from react-admin and react-autosuggest in material-ui. And I decorate my component with addField
for using redux-form with.
But has the fetch and the selection is working good, when I put my component in a SimpleForm
all the input have a value in the redux store but not mine. When I look in react dev tools, there is a Field
component arround my component
I try to do it manually via change
from redux-form but it doesn't work.
How can I connect my component in the redux store for submit all my input ?
export default connect(
null,
{
getSearched: crudGetAll,
},
)(
compose(
addField,
translate,
)(ButtonSearchWithAutocompletion),
);
onSuggestionSelected = (event, { suggestion }) => {
const { onSelectedValue, source } = this.props;
change(REDUX_FORM_NAME, source, suggestion.id);
onSelectedValue(suggestion);
};
Someone in my team help me to solve the problem, for anybody facing the same issue, the solution was, to put the change
of redux-form
in my index.js like this :
import { change } from 'redux-form';
import { connect } from 'react-redux';
import compose from 'recompose/compose';
import ButtonSearchWithAutocompletion from './component';
export default connect(
null,
{
getSearched: crudGetAll,
change,
},
)(
compose(
addField,
translate,
)(ButtonSearchWithAutocompletion),
);
And in my component.js I use the change
as props :
onSuggestionSelected = (event, { suggestion }) => {
const { onSelectedValue, source, change } = this.props;
change(REDUX_FORM_NAME, source, suggestion.id);
onSelectedValue(suggestion);
};
Hope this help !