I want to dispatch a function in redux-forms after clicking loadMore , I have already fetched data from API and I just need to render slice of records at at time.
const mapDispatchToProps = (dispatch) => {
return {
loadMore: (value) => {
dispatch(value);
},
}}
loadMore = () => {
this.setState({
pageNo: this.state.pageNo + 2,
}, () => {
setTimeout(() => {
console.log(this.props);
this.props.loadMore(this.getData())
}, 200);
});
}
<FieldArray name="getData"
component={this.getData}
/>
getData= ({ fields, meta: { error, submitFailed } }) => {
let fetchFields = fields.getAll();
let displayFetchedFields = fetchFields.slice(0, this.state.pageNo);
if (displayFetchedFields) {
return displayFetchedFields.map((facility, index) => {
}
}}
After clicking load more Error Comes : get.js:63 Uncaught TypeError: Cannot read property 'fields' of undefined