{"action":"created","issue":{"url":"https://api.github.com/repos/mobxjs/mobx-react-lite/issues/23","repository_url":"https://api.github.com/repos/mobxjs/mobx-react-lite","labels_url":"https://api.github.com/repos/mobxjs/mobx-react-lite/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/mobxjs/mobx-react-lite/issues/23/comments","events_url":"https://api.github.com/repos/mobxjs/mobx-react-lite/issues/23/events","html_url":"https://github.com/mobxjs/mobx-react-lite/issues/23","id":381947497,"node_id":"MDU6SXNzdWUzODE5NDc0OTc=","number":23,"title":"Idea: Add useObserver","user":{"login":"FredyC","id":1096340,"node_id":"MDQ6VXNlcjEwOTYzNDA=","avatar_url":"https://avatars0.githubusercontent.com/u/1096340?v=4","gravatar_id":"","url":"https://api.github.com/users/FredyC","html_url":"https://github.com/FredyC","followers_url":"https://api.github.com/users/FredyC/followers","following_url":"https://api.github.com/users/FredyC/following{/other_user}","gists_url":"https://api.github.com/users/FredyC/gists{/gist_id}","starred_url":"https://api.github.com/users/FredyC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FredyC/subscriptions","organizations_url":"https://api.github.com/users/FredyC/orgs","repos_url":"https://api.github.com/users/FredyC/repos","events_url":"https://api.github.com/users/FredyC/events{/privacy}","received_events_url":"https://api.github.com/users/FredyC/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-18T10:27:42Z","updated_at":"2018-11-18T10:29:21Z","closed_at":null,"author_association":"COLLABORATOR","body":"```js\r\nfunction MyObserverComponent(props) {\r\n  const observe = useObserver();\r\n\r\n  return observe(() => {\r\n    return <div>props.observable.x</div>\r\n  });\r\n}\r\n```\r\n\r\nI think it could have several advantages:\r\n1. you can specify the exact specific piece of code that runs inside the reaction tracking, so you can do observable mutations outside it easily without triggering unwanted renders\r\n2. you can memo your component, forward ref it or whatever you want without observer getting in the middle\r\n\r\nMaybe the only disadvantage though is that you actually have to write \"observe\" or whatever name you assigned over the render phase though\r\n\r\nMaybe offer it as an alternative to \"observer\" at least for advance use cases?\r\n\r\nobserver uses something like that internally anyway\r\n\r\n_Originally posted by @xaviergonz in https://github.com/mobxjs/mobx-react-lite/issues/7#issuecomment-439679656_"},"comment":{"url":"https://api.github.com/repos/mobxjs/mobx-react-lite/issues/comments/439682342","html_url":"https://github.com/mobxjs/mobx-react-lite/issues/23#issuecomment-439682342","issue_url":"https://api.github.com/repos/mobxjs/mobx-react-lite/issues/23","id":439682342,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTY4MjM0Mg==","user":{"login":"FredyC","id":1096340,"node_id":"MDQ6VXNlcjEwOTYzNDA=","avatar_url":"https://avatars0.githubusercontent.com/u/1096340?v=4","gravatar_id":"","url":"https://api.github.com/users/FredyC","html_url":"https://github.com/FredyC","followers_url":"https://api.github.com/users/FredyC/followers","following_url":"https://api.github.com/users/FredyC/following{/other_user}","gists_url":"https://api.github.com/users/FredyC/gists{/gist_id}","starred_url":"https://api.github.com/users/FredyC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FredyC/subscriptions","organizations_url":"https://api.github.com/users/FredyC/orgs","repos_url":"https://api.github.com/users/FredyC/repos","events_url":"https://api.github.com/users/FredyC/events{/privacy}","received_events_url":"https://api.github.com/users/FredyC/received_events","type":"User","site_admin":false},"created_at":"2018-11-18T10:29:21Z","updated_at":"2018-11-18T10:29:21Z","author_association":"COLLABORATOR","body":"I think it might be an interesting alternative to the `observer` is not polluting the tree. Question is, wouldn't that be somewhat confusing to have a 3rd option? How would user decide what to use?"}}
{"actor":{"display_login":"FredyC"}}