{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/5197","labels_url":"https://api.github.com/repos/facebook/react/issues/5197/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/5197/comments","events_url":"https://api.github.com/repos/facebook/react/issues/5197/events","html_url":"https://github.com/facebook/react/issues/5197","id":111886007,"number":5197,"title":"React Performance with bound functions","user":{"login":"ccorcos","id":1794527,"avatar_url":"https://avatars.githubusercontent.com/u/1794527?v=3","gravatar_id":"","url":"https://api.github.com/users/ccorcos","html_url":"https://github.com/ccorcos","followers_url":"https://api.github.com/users/ccorcos/followers","following_url":"https://api.github.com/users/ccorcos/following{/other_user}","gists_url":"https://api.github.com/users/ccorcos/gists{/gist_id}","starred_url":"https://api.github.com/users/ccorcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccorcos/subscriptions","organizations_url":"https://api.github.com/users/ccorcos/orgs","repos_url":"https://api.github.com/users/ccorcos/repos","events_url":"https://api.github.com/users/ccorcos/events{/privacy}","received_events_url":"https://api.github.com/users/ccorcos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-16T18:32:03Z","updated_at":"2015-10-16T18:36:41Z","closed_at":null,"body":"When I'm abstracting a components, I sometimes find it necessary to bind a function to a parameter before passing it to a child component. \r\n\r\nFor example, if I have a list of counters, we want to bind the increment prop to increment the appropriate counter.\r\n\r\n```js\r\ncounts.map((count,i) => {\r\n return <Counter count={count}  inc={this.incCount.bind(this, i)/>\r\n})\r\n```\r\n\r\nThis always returns a new function even though incCount, this, and i are all referentially equal. But every time you bind them, you get a new function. \r\n\r\nIt also wouldnt make sense to entirely rewrite counter to accept incAtIndex and index.\r\n\r\nAnd it seems crazy to create some kind of helper component.\r\n\r\n```js\r\n<BoundFunc f={this.incCount} args={[i]} props={{count}} render={(f, props} => {\r\n  return <Counter {...props} inc={c}/>\r\n}}/>\r\n```\r\n\r\nAnyways, has there been any thought put into this? It would be amazing (and help with performance) if there was some way (perhaps non-native way) that we can accomplish the following, specifially in react\r\n\r\n```js\r\na = f.bind(x,y)\r\nb = f.bind(x,y)\r\na === b\r\n// => true!\r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/148799348","html_url":"https://github.com/facebook/react/issues/5197#issuecomment-148799348","issue_url":"https://api.github.com/repos/facebook/react/issues/5197","id":148799348,"user":{"login":"syranide","id":1714255,"avatar_url":"https://avatars.githubusercontent.com/u/1714255?v=3","gravatar_id":"","url":"https://api.github.com/users/syranide","html_url":"https://github.com/syranide","followers_url":"https://api.github.com/users/syranide/followers","following_url":"https://api.github.com/users/syranide/following{/other_user}","gists_url":"https://api.github.com/users/syranide/gists{/gist_id}","starred_url":"https://api.github.com/users/syranide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syranide/subscriptions","organizations_url":"https://api.github.com/users/syranide/orgs","repos_url":"https://api.github.com/users/syranide/repos","events_url":"https://api.github.com/users/syranide/events{/privacy}","received_events_url":"https://api.github.com/users/syranide/received_events","type":"User","site_admin":false},"created_at":"2015-10-16T18:36:41Z","updated_at":"2015-10-16T18:36:41Z","body":"Personally I use a special PureRenderMixin:ish base class that ignores functions when comparing prev/next, far from perfect, but works well enough.\r\n\r\n@jimfb The problem is that if every component you create receives a bound function, then *all* components will re-render every time."}}