{"action":"created","issue":{"url":"https://api.github.com/repos/airbnb/react-dates/issues/299","repository_url":"https://api.github.com/repos/airbnb/react-dates","labels_url":"https://api.github.com/repos/airbnb/react-dates/issues/299/labels{/name}","comments_url":"https://api.github.com/repos/airbnb/react-dates/issues/299/comments","events_url":"https://api.github.com/repos/airbnb/react-dates/issues/299/events","html_url":"https://github.com/airbnb/react-dates/issues/299","id":205613154,"number":299,"title":"Why use double-wrapped handlers in CalendarDay?","user":{"login":"evandavis","id":971616,"avatar_url":"https://avatars.githubusercontent.com/u/971616?v=3","gravatar_id":"","url":"https://api.github.com/users/evandavis","html_url":"https://github.com/evandavis","followers_url":"https://api.github.com/users/evandavis/followers","following_url":"https://api.github.com/users/evandavis/following{/other_user}","gists_url":"https://api.github.com/users/evandavis/gists{/gist_id}","starred_url":"https://api.github.com/users/evandavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evandavis/subscriptions","organizations_url":"https://api.github.com/users/evandavis/orgs","repos_url":"https://api.github.com/users/evandavis/repos","events_url":"https://api.github.com/users/evandavis/events{/privacy}","received_events_url":"https://api.github.com/users/evandavis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-06T15:12:44Z","updated_at":"2017-02-07T00:13:14Z","closed_at":null,"body":"The event handlers in `CalendarDay` are wrapped twice; first as an anonymous handler:\r\n```js\r\nonMouseEnter={e => this.onDayMouseEnter(day, e)}\r\n```\r\n\r\nand then again as a method on the class:\r\n```js\r\nonDayMouseEnter(day, e) {\r\n  const { onDayMouseEnter } = this.props;\r\n  onDayMouseEnter(day, e);\r\n}\r\n```\r\n\r\nWhy? What's the benefit vs doing either `onMouseEnter={e => this.props.onDayMouseEnter(day, e)}` inline or\r\n```js\r\n<div onMouseEnter={this.onDayMouseEnter} />\r\n\r\n// and\r\n\r\nonDayMouseEnter(e) {\r\n  const { day, onDayMouseEnter } = this.props;\r\n  onDayMouseEnter(day, e);\r\n}\r\n``` \r\non the class?"},"comment":{"url":"https://api.github.com/repos/airbnb/react-dates/issues/comments/277857411","html_url":"https://github.com/airbnb/react-dates/issues/299#issuecomment-277857411","issue_url":"https://api.github.com/repos/airbnb/react-dates/issues/299","id":277857411,"user":{"login":"ljharb","id":45469,"avatar_url":"https://avatars.githubusercontent.com/u/45469?v=3","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"created_at":"2017-02-07T00:13:14Z","updated_at":"2017-02-07T00:13:14Z","body":"The important things to ensure are:\r\n - `this.props.onDayMouseEnter` is not called with a receiver (a `this` value) (the inline example you provided violates this)\r\n - as much logic as possible is in instance methods and not in arrows or bound functions, so that engine can optimize them (doing everything in an inline arrow would violate this)\r\n - event handlers should not have return values (your inline example violates this, and the direct reference doesn't ensure that nobody adds a return value later)"}}
{"actor":{"display_login":"ljharb"}}