原始问题:https ://github.com/acdlite/recompose/issues/232
如何访问 BaseComponent 或任何级别的组件的引用?
代码:
class BaseComponent {
doSth(){...}
}
const Component compose(...some)(BaseComponent);
class App {
componentDidMount() {
// undefined(doSth) is not a function
this.refs.component.doSth();
}
render() {
<Component ref="component" />
}
}