Categories
Development React

how to implement pagination in redux forms using fields.map function (react js)

I need to render 10 records in redux forms which are fetched from API 100 records at a time. Is it possible to map only a portion of an array? (fields.map()) function. Please help me by adding a function which helps to render 10 records at a time instead of complete redux fields

constructor(props) {
        super(props)
        this.state = {
            pageNo: 1,
        }
    }

loadMore() {
        this.setState({
            pageNo: this.state.pageNo + 1,
        })
    }


getFacilities = ({ fields, meta: { error, submitFailed } }) => {
        const { facilityDataInputs } = this.props;
        if (facilityDataInputs) {
            return fields.map(element) => {
              console.log('index');
            });
        }
    }

console.log(this.props.facilityDataInputs) // it is an array fetched
from mapStateToProps having length 5

I want to render 10 records at a time in the component but i am not
able to use slice function in redux fields
enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *