ant D源码中form组件只对是react-component form的一层封装
首先表单是双向绑定的

form在react中是怎么实现数据的双向绑定的?
在react中我们可以手动去绑定input框的值为一个state中的值,然后每次onchange时去更新state
刚看到createBaseForm.js的源码时,我猜测,reactForm也是这样实现的

默认的触发器就是onchange,再来看实现流程是怎么样的

createBaseForm返回一个高阶函数decorate

这里采用es5的类写法,getInitialState相当于Es6 Class中的constructor部分,在生成一个表单实例时就会有一个fieldsStore对象,通读全文后发现,很多复杂操都是在对这个全局store进行维护

getFieldDecorator是一个高阶函数,将传入的组件封装后返回
- 核心部分onChange的封装



在onCollect部分先通过onCollectCommon实现了原action也就是onChange的执行,再setFields更新当前表单的值

更新store后,强制刷新

这里已经能够大概知道form内部是怎么运作的了,我画了一张流程图

根据原理做了一个简单的demo
- npm
https://www.npmjs.com/package/zjx-react-form
- 码云
Pretty! This has been an extremely wonderful article. Many thanks for providing this info.
pressured me to try and do it! Your writing style has been amazed me.
present here at this blog, thanks admin of this
Pretty great post. I simply stumbled upon your blog and wanted to mention that
Pretty! This was an extremely wonderful article. Many thanks for supplying these details.
Pretty section of content. I just stumbled upon your site and in accession capital to assert that I get actually
Pretty nice post. I just stumbled upon your weblog and wished to say that I’ve truly enjoyed surfing around
post, we want develop more techniques on this regard, thanks for
Pretty portion of content. I simply stumbled upon your site and in accession capital to say that I get in fact loved account
Please let me know where you got your theme. Kudos
Pretty sure he will have a good read. Many thanks for sharing!
Perhaps you could write next articles referring to
Please let me know where you got your theme. Thanks
Pretty nice post. I just stumbled upon your weblog and wished to say that I have truly enjoyed browsing your blog posts. After all I will be subscribing to your feed and I hope you write again very soon!
Pretty nice post. I just stumbled upon your weblog and wished to say that I’ve truly enjoyed surfing around
Pretty nice post. I just stumbled upon your
Pretty! This was an extremely wonderful post. Many thanks for providing these details.
Please let me know. Thank you
posts a little bit more interesting.
presented it. Too cool!
Pretty nice post. I just stumbled upon your weblog and
Pretty nice post. I just stumbled upon your
Power is lived way oh every in we tranquillize.
posts. Any way I will be subscribing to your feeds and even I achievement you access consistently quickly.
Pretty portion of content. I simply stumbled upon your site and in accession capital to say that I get in fact loved account
Please shoot me an email if interested. Cheers!
Pretty nice post. I just stumbled upon your weblog and wished to say that I’ve really enjoyed browsing your blog posts. After all I will be subscribing to your rss feed and I hope you write again very soon!
Pretty! This has been an incredibly wonderful article. Many thanks for supplying these details.
posts. Any way I will be subscribing to your feeds and even I achievement you access consistently quickly.
Pretty! This was an incredibly wonderful article. Thanks for providing these details.
post on building up new weblog.
porn watch
platform.
Ouasck ymyxpp Viagra medication Drug viagra
Pretty! This has been an extremely wonderful article. Thank you for providing these details.
porn watch
page layout of your blog? Its very well written; I love what youve got to
Pretty! This has been a really wonderful article. Thanks for supplying these details.
Pretty nice post. I just stumbled upon your blog and wished to say that I’ve really enjoyed surfing around your blog posts.
Please do keep up the excellent work.
Pretty great post. I simply stumbled upon your weblog and wanted to say that I have really enjoyed surfing around
Pretty nice post. I just stumbled upon your blog and wished to say that I’ve really enjoyed surfing around your blog posts.
Perhaps you can write subsequent articles relating to this
Practice daily to ensure you get better.
post that you simply made some days ago? Any positive?
Pretty nice post. I just stumbled upon your blog and wanted to say that I have truly enjoyed surfing around your blog posts. After all I’ll be subscribing to your rss feed and I hope you write again soon!
pretty much the same layout and design. Wonderful choice of colors!
Practice with another person, and try dribbling the ball around in a square.
particular info for a very long time. Thank you and best of luck.
Pretty portion of content. I simply stumbled upon your site and in accession capital to say that I get in fact loved account