2016-09-09 23 views

回答

2

您可以使用hoistStatic

class BaseComponent { 
    doSth(){...} 
} 

const enhance = compose(...some) 

const Component = hoistStatics(enhance)(BaseComponent) 

class App { 
    componentDidMount() { 
    this.refs.component.doSth() 
    } 
    render() { 
    <Component ref="component" /> 
    } 
} 

你可以找到一個真實的例子in the test

相關問題