{"action":"created","issue":{"url":"https://api.github.com/repos/iddan/react-native-canvas/issues/76","repository_url":"https://api.github.com/repos/iddan/react-native-canvas","labels_url":"https://api.github.com/repos/iddan/react-native-canvas/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/iddan/react-native-canvas/issues/76/comments","events_url":"https://api.github.com/repos/iddan/react-native-canvas/issues/76/events","html_url":"https://github.com/iddan/react-native-canvas/issues/76","id":355834435,"node_id":"MDU6SXNzdWUzNTU4MzQ0MzU=","number":76,"title":"How to trigger re-render?","user":{"login":"joshuajenkins","id":38473,"node_id":"MDQ6VXNlcjM4NDcz","avatar_url":"https://avatars1.githubusercontent.com/u/38473?v=4","gravatar_id":"","url":"https://api.github.com/users/joshuajenkins","html_url":"https://github.com/joshuajenkins","followers_url":"https://api.github.com/users/joshuajenkins/followers","following_url":"https://api.github.com/users/joshuajenkins/following{/other_user}","gists_url":"https://api.github.com/users/joshuajenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/joshuajenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshuajenkins/subscriptions","organizations_url":"https://api.github.com/users/joshuajenkins/orgs","repos_url":"https://api.github.com/users/joshuajenkins/repos","events_url":"https://api.github.com/users/joshuajenkins/events{/privacy}","received_events_url":"https://api.github.com/users/joshuajenkins/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-31T04:19:11Z","updated_at":"2018-09-02T15:54:50Z","closed_at":null,"author_association":"NONE","body":"Please bear with what I know is a simple question. I'm struggling to wrap my head around how to get the canvas to re-render. Take this naive example (assume `randomColor()` is a real function — I simplified this example).\r\n\r\n```\r\nimport React, {Component} from 'react'\r\nimport {TouchableOpacity} from 'react-native'\r\nimport Canvas from 'react-native-canvas'\r\n\r\nexport default class CanvasPlayground extends Component {\r\n\r\n\tconstructor() {\r\n\t\tsuper()\r\n\t\tthis.state = {\r\n\t\t\tcolor: randomColor()\r\n\t\t}\r\n\t}\r\n\r\n\thandleCanvas = canvas => {\r\n\t\tconst ctx = canvas.getContext('2d')\r\n\t\tctx.fillStyle = this.state.color\r\n\t\tctx.fillRect(0, 0, 100, 100)\r\n\t}\r\n\r\n\trender() {\r\n\t\treturn (\r\n\t\t\t<TouchableOpacity\r\n\t\t\t\tonPress={this.handleTouch}>\r\n\t\t\t\t<Canvas ref={this.handleCanvas} />\r\n\t\t\t</TouchableOpacity>\r\n\t\t)\r\n\t}\r\n\r\n\thandleTouch = () => {\r\n\t\tthis.setState({\r\n\t\t\tcolor: randomColor()\r\n\t\t})\r\n\t}\r\n}\r\n```\r\n\r\nMy (clearly wrong) expectation is that changing the state would cause a re-render, but obviously that's not the case. Any tips on how I can think about this correctly? What's the naive way to model tapping a View that causes the canvas to re-render?\r\n\r\nThanks, and apologies for what I'm sure is a stupid question. I'm stuck nonetheless."},"comment":{"url":"https://api.github.com/repos/iddan/react-native-canvas/issues/comments/417940379","html_url":"https://github.com/iddan/react-native-canvas/issues/76#issuecomment-417940379","issue_url":"https://api.github.com/repos/iddan/react-native-canvas/issues/76","id":417940379,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzk0MDM3OQ==","user":{"login":"iddan","id":12671072,"node_id":"MDQ6VXNlcjEyNjcxMDcy","avatar_url":"https://avatars2.githubusercontent.com/u/12671072?v=4","gravatar_id":"","url":"https://api.github.com/users/iddan","html_url":"https://github.com/iddan","followers_url":"https://api.github.com/users/iddan/followers","following_url":"https://api.github.com/users/iddan/following{/other_user}","gists_url":"https://api.github.com/users/iddan/gists{/gist_id}","starred_url":"https://api.github.com/users/iddan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iddan/subscriptions","organizations_url":"https://api.github.com/users/iddan/orgs","repos_url":"https://api.github.com/users/iddan/repos","events_url":"https://api.github.com/users/iddan/events{/privacy}","received_events_url":"https://api.github.com/users/iddan/received_events","type":"User","site_admin":false},"created_at":"2018-09-02T15:54:50Z","updated_at":"2018-09-02T15:54:50Z","author_association":"OWNER","body":"Something like this? https://blog.lavrton.com/using-react-with-html5-canvas-871d07d8d753\r\n"}}
{"actor":{"display_login":"iddan"}}