react-component / form

React High Order Form Component(web & react-native)
http://react-component.github.io/form/
MIT License
1.81k stars 295 forks source link

Should it be allow to use ref on EnhancedForm? #351

Open vizonluo opened 4 years ago

vizonluo commented 4 years ago

I want to use ref to get instance of EnhancedForm. It could be use validateFields and so on methods easily. But I get a warning

Warning: you should not use `ref` on enhanced form, please use `wrappedComponentRef`. See: https://github.com/react-component/form#note-use-wrappedcomponentref-instead-of-withref-after-rc-form140

I have see the content of the link. The aim of the example is to get instance of original Form. But i want to get instance of EnhancedForm. It's easily to use ref on EnhancedForm. example like this

class Form extends React.Component { ... }

const EnhancedForm = createForm()(Form);
<EnhancedForm ref="form" />
this.refs.form  // => The instance of EnhancedForm

const EnhancedForm = createForm()(Form);
<EnhancedForm wrappedComponentRef={(inst) => this.formRef = inst} />
this.formRef // => The instance of Form, it seems it no way to get instance of EnhancedForm

Otherwise, the name of wrappedComponentRef look like refer to EnhancedForm, but it refer to original form