代码如下:

我使用了官方推荐的wrappedComponentRef方式,获取到了子组件的实例,但是打印出来却不是自己所期望的那样有method方法
请问下我是哪里写错了,还是这种官网并没有挂载自定义方法上去啊?
这是参考的例子:
https://github.com/react-comp...
这是官网的说明:
https://github.com/react-comp...
有以下片段代码:
class Form extends React.Component { ... }
// deprecated
const EnhancedForm = createForm({ withRef: true })(Form);
<EnhancedForm ref="form" />
this.refs.form.refs.wrappedComponent // => The instance of Form
// Recommended
const EnhancedForm = createForm()(Form);
<EnhancedForm wrappedComponentRef={(inst) => this.formRef = inst} />
this.formRef // => The instance of Form
这个问题困扰了不少人啊,有哪位大侠出手相助啊!
临摹微笑
微微去
函数式编程
青春有我
随时随地看视频慕课网APP
相关分类