代码如下:我使用了官方推荐的wrappedComponentRef方式,获取到了子组件的实例,但是打印出来却不是自己所期望的那样有method方法请问下我是哪里写错了,还是这种官网并没有挂载自定义方法上去啊?这是参考的例子:https://github.com/react-comp...这是官网的说明:https://github.com/react-comp...有以下片段代码:class Form extends React.Component { ... }// deprecatedconst EnhancedForm = createForm({ withRef: true })(Form);<EnhancedForm ref="form" />this.refs.form.refs.wrappedComponent // => The instance of Form// Recommendedconst EnhancedForm = createForm()(Form);<EnhancedForm wrappedComponentRef={(inst) => this.formRef = inst} />this.formRef // => The instance of Form这个问题困扰了不少人啊,有哪位大侠出手相助啊!
添加回答
举报
0/150
提交
取消