Fix bug to get wrapped component prop name list

This commit is contained in:
taehoon 2019-02-25 04:18:41 -05:00
parent 5c43374588
commit cb383df517
3 changed files with 14 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import Vue from 'vue'
import filter from 'lodash/filter'
import isEmpty from 'lodash/isEmpty'
import { getComponentProps } from '../../services/component_utils/component_utils'
import './with_load_more.scss'
const withLoadMore = ({
@ -9,7 +10,7 @@ const withLoadMore = ({
childPropName = 'entries', // name of the prop to be passed into the wrapped component
additionalPropNames = [] // additional prop name list of the wrapper component
}) => (WrappedComponent) => {
const originalProps = WrappedComponent.props || []
const originalProps = Object.keys(getComponentProps(WrappedComponent))
const props = filter(originalProps, v => v !== childPropName).concat(additionalPropNames)
return Vue.component('withLoadMore', {

View File

@ -1,6 +1,7 @@
import Vue from 'vue'
import filter from 'lodash/filter'
import isEmpty from 'lodash/isEmpty'
import { getComponentProps } from '../../services/component_utils/component_utils'
import './with_subscription.scss'
const withSubscription = ({
@ -9,7 +10,7 @@ const withSubscription = ({
childPropName = 'content', // name of the prop to be passed into the wrapped component
additionalPropNames = [] // additional prop name list of the wrapper component
}) => (WrappedComponent) => {
const originalProps = WrappedComponent.props || []
const originalProps = Object.keys(getComponentProps(WrappedComponent))
const props = filter(originalProps, v => v !== childPropName).concat(additionalPropNames)
return Vue.component('withSubscription', {

View File

@ -0,0 +1,10 @@
import isFunction from 'lodash/isFunction'
const getComponentOptions = (Component) => (isFunction(Component)) ? Component.options : Component
const getComponentProps = (Component) => getComponentOptions(Component).props
export {
getComponentOptions,
getComponentProps
}