【发布时间】:2023-04-02 05:30:01
【问题描述】:
原问题:https://github.com/acdlite/recompose/issues/232
如何访问 BaseComponent 或任何级别的组件的 ref?
代码:
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" />
}
}
【问题讨论】: