{"action":"created","issue":{"url":"https://api.github.com/repos/acdlite/recompose/issues/18","labels_url":"https://api.github.com/repos/acdlite/recompose/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/acdlite/recompose/issues/18/comments","events_url":"https://api.github.com/repos/acdlite/recompose/issues/18/events","html_url":"https://github.com/acdlite/recompose/issues/18","id":110984131,"number":18,"title":"Internal state without setState","user":{"login":"istarkov","id":5077042,"avatar_url":"https://avatars.githubusercontent.com/u/5077042?v=3","gravatar_id":"","url":"https://api.github.com/users/istarkov","html_url":"https://github.com/istarkov","followers_url":"https://api.github.com/users/istarkov/followers","following_url":"https://api.github.com/users/istarkov/following{/other_user}","gists_url":"https://api.github.com/users/istarkov/gists{/gist_id}","starred_url":"https://api.github.com/users/istarkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istarkov/subscriptions","organizations_url":"https://api.github.com/users/istarkov/orgs","repos_url":"https://api.github.com/users/istarkov/repos","events_url":"https://api.github.com/users/istarkov/events{/privacy}","received_events_url":"https://api.github.com/users/istarkov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-12T14:22:29Z","updated_at":"2015-10-12T14:30:39Z","closed_at":null,"body":"There are situations at almost all controls I've wrote when I need to hold some state but this state isn't React or Flux state. Because I don't want additional rerender.\r\n\r\nFor example:\r\n\r\n```javascript\r\n  _onMouseEnter(poly) {\r\n    clearTimeout(this.mouseLeaveTimeoutHandle_);\r\n    onHoveredChange(poly);\r\n  }\r\n\r\n  _onMouseLeave( /* poly */ ) {\r\n    this.mouseLeaveTimeoutHandle_ = setTimeout(\r\n      () => onHoveredChange(null),\r\n      1000 / 60\r\n    );\r\n  }\r\n```\r\n\r\nHere I use  `this.mouseLeaveTimeoutHandle_` to prevent rerender if Mouse enter new object.\r\nSometimes such `state` used as cache, sometimes to support imperative DOM calls.\r\n\r\nMay be recompose needs something like `withState` but with `getter` functions support and without `setState` calls?\r\n\r\n(For such state Getter Setter functions (or one function) are passed through props, not a value)\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/acdlite/recompose/issues/comments/147413809","html_url":"https://github.com/acdlite/recompose/issues/18#issuecomment-147413809","issue_url":"https://api.github.com/repos/acdlite/recompose/issues/18","id":147413809,"user":{"login":"istarkov","id":5077042,"avatar_url":"https://avatars.githubusercontent.com/u/5077042?v=3","gravatar_id":"","url":"https://api.github.com/users/istarkov","html_url":"https://github.com/istarkov","followers_url":"https://api.github.com/users/istarkov/followers","following_url":"https://api.github.com/users/istarkov/following{/other_user}","gists_url":"https://api.github.com/users/istarkov/gists{/gist_id}","starred_url":"https://api.github.com/users/istarkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istarkov/subscriptions","organizations_url":"https://api.github.com/users/istarkov/orgs","repos_url":"https://api.github.com/users/istarkov/repos","events_url":"https://api.github.com/users/istarkov/events{/privacy}","received_events_url":"https://api.github.com/users/istarkov/received_events","type":"User","site_admin":false},"created_at":"2015-10-12T14:30:39Z","updated_at":"2015-10-12T14:30:39Z","body":"I can share such state using \r\n```javascript\r\n@mapProps(p => {\r\n   let internalState = 0;\r\n   return {\r\n      ...p,\r\n      incInternalState() {\r\n        ++internalState; \r\n      },\r\n      getInternalState() {\r\n        return internalState; \r\n      },\r\n   };\r\n})\r\n```\r\nMay be this enough.\r\n"}}