You call it from the componentDidMount () component of the response component for your page, or where it makes sense. So, in this component file:
import { requestPageOfPlans } from 'actions'; import React from 'react'; import { connect } from 'react-redux'; class MyComponent extends React.Component { componentDidMount() { this.props.requestPageOfPlans(); } } export default connect((state) => state, { requestPageOfPlans })(MyComponent);
So, the key here is to configure the connection. The first parameter is how you want to convert the state (your gears) into the data for the props. Adjust it as you need. Secondly, what actions do you want to link. You can also import the newsletter manually, but I personally like this template. It sets up actions as a props for a component, and you can name it that way. Just pass the arguments as you need. This page here: https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options explains the connection function in more detail.
Edit
Given that you are paginating, you need to configure the connect mapStateToProps function to transfer the pagination data to the component, and then scroll to display what you need. Personally, I did pagination in the background and just made new requests for each page. Depends on how many records you expect.
So, in the connection, do something like this:
export default connect((state) => { return { startIndex: state.paging.lastIndex, pageSize: state.paging.pageSize, lastIndex: state.paging.lastIndex, plans: state.plans }; }, { requestPageOfPlans })(MyComponent);
Then, in your component, swipe the plan using these indexes:
render() { const plans = []; const maxIndex = Math.min(this.props.startIndex + this.props.pageSize, this.props.lastIndex); for (let i = this.props.startIndex || 0; i < maxIndex; i++) { const plan = this.props.plans[i]; plans.push(<Plan key={plan.id} plan={plan} />); } return ( <ul>{plans}</ul> ); }
We repeat some assumptions about how you plan to display it, if you have a component called Plan, etc. But thatβs about how you can work with it.