{"action":"closed","issue":{"url":"https://api.github.com/repos/facebook/react/issues/14328","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/14328/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/14328/comments","events_url":"https://api.github.com/repos/facebook/react/issues/14328/events","html_url":"https://github.com/facebook/react/issues/14328","id":384404839,"node_id":"MDU6SXNzdWUzODQ0MDQ4Mzk=","number":14328,"title":"Inconsistent setState behavior while using controlled components","user":{"login":"mvbattan","id":11986709,"node_id":"MDQ6VXNlcjExOTg2NzA5","avatar_url":"https://avatars1.githubusercontent.com/u/11986709?v=4","gravatar_id":"","url":"https://api.github.com/users/mvbattan","html_url":"https://github.com/mvbattan","followers_url":"https://api.github.com/users/mvbattan/followers","following_url":"https://api.github.com/users/mvbattan/following{/other_user}","gists_url":"https://api.github.com/users/mvbattan/gists{/gist_id}","starred_url":"https://api.github.com/users/mvbattan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvbattan/subscriptions","organizations_url":"https://api.github.com/users/mvbattan/orgs","repos_url":"https://api.github.com/users/mvbattan/repos","events_url":"https://api.github.com/users/mvbattan/events{/privacy}","received_events_url":"https://api.github.com/users/mvbattan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-26T16:17:59Z","updated_at":"2018-11-26T16:55:08Z","closed_at":"2018-11-26T16:55:08Z","author_association":"NONE","body":"<!--\r\n  Note: if the issue is about documentation or the website, please file it at:\r\n  https://github.com/reactjs/reactjs.org/issues/new\r\n-->\r\n\r\n**Do you want to request a *feature* or report a *bug*?**\r\nI want to report a bug.\r\n\r\n**What is the current behavior?**\r\nWhile using an input as controlled component:\r\n```\r\n<input\r\n  type=\"input\"\r\n  value={this.state.inputValue}\r\n  onChange={this.handleChange}\r\n/>\r\n```\r\nwriting\r\n```\r\n handleChange = e => {\r\n   this.setState({ inputValue: e.target.value });\r\n };\r\n```\r\nworks well but using functional `setState`\r\n```\r\n handleChange = e => {\r\n   this.setState(() => ({ inputValue: e.target.value }));\r\n };\r\n```\r\ncrashes with `TypeError: Cannot read property 'value' of null`\r\n \r\n**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:**\r\n\r\nWorking example:\r\nhttps://jsfiddle.net/Luktwrdm/1435/\r\n\r\nCrashing example (using functional setState)\r\nhttps://jsfiddle.net/Luktwrdm/1436/\r\n\r\nDemo:\r\n![reactbug](https://user-images.githubusercontent.com/11986709/49026581-fac12200-f17c-11e8-88e6-bb76745b0a7d.gif)\r\n\r\n\r\n**What is the expected behavior?**\r\nThe expected behavior is that both `setState` (with object and with function) should have the same behavior for end-users.\r\n\r\n**Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?**\r\nBrowser: Google Chrome Version 70.0.3538.102 (Official Build) (64-bit)\r\nReact Version: 16.6.1\r\n"}}
{"actor":{"display_login":"mvbattan"}}