Rename some options and add comments to HOCs
This commit is contained in:
parent
339373b495
commit
6d4d705c51
4 changed files with 20 additions and 9 deletions
|
@ -3,7 +3,11 @@ import filter from 'lodash/filter'
|
|||
import isEmpty from 'lodash/isEmpty'
|
||||
import './with_load_more.scss'
|
||||
|
||||
const withLoadMore = ({ fetch, select, entriesPropName = 'entries' }) => (WrappedComponent) => {
|
||||
const withLoadMore = ({
|
||||
fetch, // function to fetch entries and return a promise
|
||||
select, // function to select data from store
|
||||
childPropName = 'entries' // name of the prop to be passed into the wrapped component
|
||||
}) => (WrappedComponent) => {
|
||||
const originalProps = WrappedComponent.props || []
|
||||
const props = filter(originalProps, v => v !== 'entries')
|
||||
|
||||
|
@ -12,7 +16,7 @@ const withLoadMore = ({ fetch, select, entriesPropName = 'entries' }) => (Wrappe
|
|||
const props = {
|
||||
props: {
|
||||
...this.$props,
|
||||
[entriesPropName]: this.entries
|
||||
[childPropName]: this.entries
|
||||
},
|
||||
on: this.$listeners
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue