{"action":"created","issue":{"url":"https://api.github.com/repos/ant-design/ant-design/issues/4513","repository_url":"https://api.github.com/repos/ant-design/ant-design","labels_url":"https://api.github.com/repos/ant-design/ant-design/issues/4513/labels{/name}","comments_url":"https://api.github.com/repos/ant-design/ant-design/issues/4513/comments","events_url":"https://api.github.com/repos/ant-design/ant-design/issues/4513/events","html_url":"https://github.com/ant-design/ant-design/issues/4513","id":199338583,"number":4513,"title":"form中如果复写了shouldComponentUpdate方法，可能导致input无法输入内容","user":{"login":"pishilong","id":610081,"avatar_url":"https://avatars.githubusercontent.com/u/610081?v=3","gravatar_id":"","url":"https://api.github.com/users/pishilong","html_url":"https://github.com/pishilong","followers_url":"https://api.github.com/users/pishilong/followers","following_url":"https://api.github.com/users/pishilong/following{/other_user}","gists_url":"https://api.github.com/users/pishilong/gists{/gist_id}","starred_url":"https://api.github.com/users/pishilong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pishilong/subscriptions","organizations_url":"https://api.github.com/users/pishilong/orgs","repos_url":"https://api.github.com/users/pishilong/repos","events_url":"https://api.github.com/users/pishilong/events{/privacy}","received_events_url":"https://api.github.com/users/pishilong/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-01-07T03:42:05Z","updated_at":"2017-01-09T01:57:16Z","closed_at":"2017-01-09T01:57:16Z","body":"<!-- Issue Template -->\r\n\r\n<!--\r\nantd 的用法咨询，建议通过以下渠道，官方 issues 目前没有足够精力提供此类咨询服务：\r\n\r\n1. [Stack Overflow](http://stackoverflow.com/questions/tagged/antd)\r\n2. [Segment Fault](https://segmentfault.com/t/antd)（中文）\r\n\r\n如果是报告 bug，请按照下列格式书写，并务必提供复现步骤，否则恕难解决，感谢您的支持。\r\n-->\r\n\r\n#### Environment(required)\r\n\r\n- antd version: 2.6.0\r\n- OS and its version: MacOS Sierra\r\n- Browser and its version: 所有浏览器\r\n\r\n#### What did you do? Please provide steps to re-produce your problem.\r\n\r\n<!-- e.g. I just imported Button from antd -->\r\n1. form中添加shouldComponentUpdate方法\r\n2. 在Input中输入内容\r\n3. Input还是之前的内容，没有更新\r\n\r\n#### What do you expected?\r\n\r\n更新文档，注明不光stateless component会有问题，\r\n如果复写了shouldComponentUpdate方法可能也会有问题。\r\n\r\n#### What happen?\r\n\r\nInput中无法输入内容\r\n0.在Input中输入内容，触发onChange事件（此时input显示的是输入后的内容）\r\n1.React dispatchEvent并进行batchedUpdates\r\n2.Form的onChangeValidate能对新值进行校验\r\n3.React->flushBatchedUpdates\r\n....\r\n4.React->runBatchedUpdates\r\n5.ReactReconciler.performUpdateIfNecessary\r\n6.internalInstance.performUpdateIfNecessary(transaction);\r\n7. this.updateComponent\r\n    此时this指向的是form对象，在updateComponent方法中，会检查并执行shouldComponentUpdate方法，如果方法返回false，则form不会更新，所以刚输入内容的input也不会更新value，导致输入无效。\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ant-design/ant-design/issues/comments/271199199","html_url":"https://github.com/ant-design/ant-design/issues/4513#issuecomment-271199199","issue_url":"https://api.github.com/repos/ant-design/ant-design/issues/4513","id":271199199,"user":{"login":"pishilong","id":610081,"avatar_url":"https://avatars.githubusercontent.com/u/610081?v=3","gravatar_id":"","url":"https://api.github.com/users/pishilong","html_url":"https://github.com/pishilong","followers_url":"https://api.github.com/users/pishilong/followers","following_url":"https://api.github.com/users/pishilong/following{/other_user}","gists_url":"https://api.github.com/users/pishilong/gists{/gist_id}","starred_url":"https://api.github.com/users/pishilong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pishilong/subscriptions","organizations_url":"https://api.github.com/users/pishilong/orgs","repos_url":"https://api.github.com/users/pishilong/repos","events_url":"https://api.github.com/users/pishilong/events{/privacy}","received_events_url":"https://api.github.com/users/pishilong/received_events","type":"User","site_admin":false},"created_at":"2017-01-09T01:57:16Z","updated_at":"2017-01-09T01:57:16Z","body":"我用stateless component做类比有问题，那个是bug，这个不是bug。\r\n只是在使用getFieldDecorator时，因为使用了双向绑定，会去更新Input的value属性，所以如果在form中用了shouldComponentUpdate的话，可能会出现不刷新的情况，需要注意一下。\r\n所以希望能在文档中加个tips之类的。\r\n\r\n当然，如果觉得没必要在文档中加个tips的话也没问题。"}}
{"actor":{"display_login":"pishilong"}}