{"action":"created","issue":{"url":"https://api.github.com/repos/jayesbe/react-native-cacheable-image/issues/22","repository_url":"https://api.github.com/repos/jayesbe/react-native-cacheable-image","labels_url":"https://api.github.com/repos/jayesbe/react-native-cacheable-image/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/jayesbe/react-native-cacheable-image/issues/22/comments","events_url":"https://api.github.com/repos/jayesbe/react-native-cacheable-image/issues/22/events","html_url":"https://github.com/jayesbe/react-native-cacheable-image/issues/22","id":187633811,"number":22,"title":"setState warning","user":{"login":"sjgtongji","id":6083671,"avatar_url":"https://avatars.githubusercontent.com/u/6083671?v=3","gravatar_id":"","url":"https://api.github.com/users/sjgtongji","html_url":"https://github.com/sjgtongji","followers_url":"https://api.github.com/users/sjgtongji/followers","following_url":"https://api.github.com/users/sjgtongji/following{/other_user}","gists_url":"https://api.github.com/users/sjgtongji/gists{/gist_id}","starred_url":"https://api.github.com/users/sjgtongji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjgtongji/subscriptions","organizations_url":"https://api.github.com/users/sjgtongji/orgs","repos_url":"https://api.github.com/users/sjgtongji/repos","events_url":"https://api.github.com/users/sjgtongji/events{/privacy}","received_events_url":"https://api.github.com/users/sjgtongji/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2016-11-07T06:23:08Z","updated_at":"2016-11-21T01:37:21Z","closed_at":null,"body":"the component functions well but in debug mode, there is a warning:\r\n\r\nsetState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the CacheableImage component."},"comment":{"url":"https://api.github.com/repos/jayesbe/react-native-cacheable-image/issues/comments/261823335","html_url":"https://github.com/jayesbe/react-native-cacheable-image/issues/22#issuecomment-261823335","issue_url":"https://api.github.com/repos/jayesbe/react-native-cacheable-image/issues/22","id":261823335,"user":{"login":"jayesbe","id":3108980,"avatar_url":"https://avatars.githubusercontent.com/u/3108980?v=3","gravatar_id":"","url":"https://api.github.com/users/jayesbe","html_url":"https://github.com/jayesbe","followers_url":"https://api.github.com/users/jayesbe/followers","following_url":"https://api.github.com/users/jayesbe/following{/other_user}","gists_url":"https://api.github.com/users/jayesbe/gists{/gist_id}","starred_url":"https://api.github.com/users/jayesbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayesbe/subscriptions","organizations_url":"https://api.github.com/users/jayesbe/orgs","repos_url":"https://api.github.com/users/jayesbe/repos","events_url":"https://api.github.com/users/jayesbe/events{/privacy}","received_events_url":"https://api.github.com/users/jayesbe/received_events","type":"User","site_admin":false},"created_at":"2016-11-21T01:37:20Z","updated_at":"2016-11-21T01:37:20Z","body":"@nbolender Have to head out but made a quick patch.. if you have time to check let me know if its good?  otherwise I will look into it further tomorrow.  Thanks for the help. \r\n\r\n```\r\ndiff --git a/image.js b/image.js\r\nindex c53e479..ea6c72b 100644\r\n--- a/image.js\r\n+++ b/image.js\r\n@@ -21,8 +21,8 @@\r\n             downloading: false,\r\n             cacheable: true,\r\n             jobId: null,\r\n-            networkAvailable: false\r\n-        };\r\n+            networkAvailable: props.networkAvailable\r\n+        };  \r\n     };\r\n \r\n     componentWillReceiveProps(nextProps) {\r\n@@ -156,14 +156,14 @@\r\n \r\n     componentWillMount() {\r\n         NetInfo.isConnected.addEventListener('change', this._handleConnectivityChange);\r\n-        // initial\r\n-        NetInfo.isConnected.fetch().then(isConnected => {\r\n-            this.setState({networkAvailable: isConnected});\r\n-\t\t});\r\n+        \r\n+        if (this.props.checkNetwork) {\r\n+            NetInfo.isConnected.fetch().done(this._handleConnectivityChange);\r\n+        }\r\n         \r\n         this._processSource(this.props.source);\r\n     }\r\n-\r\n+    \r\n     componentWillUnmount() {\r\n         NetInfo.isConnected.removeEventListener('change', this._handleConnectivityChange);\r\n     \r\n@@ -215,9 +215,10 @@\r\n     }\r\n \r\n     renderDefaultSource() {\r\n-        const { children, defaultSource, ...props } = this.props;\r\n+        const { children, defaultSource, checkNetwork, ...props } = this.props;\r\n+        const { networkAvailable } = this.state;\r\n         return (\r\n-            <CacheableImage {...props} source={defaultSource}>\r\n+            <CacheableImage {...props} source={defaultSource} checkNetwork={false} networkAvailable={networkAvailable} >\r\n             {children}\r\n             </CacheableImage>\r\n         );\r\n@@ -230,7 +231,9 @@\r\n     useQueryParamsInCacheKey: React.PropTypes.oneOfType([\r\n         React.PropTypes.bool,\r\n         React.PropTypes.array\r\n-    ])\r\n+    ]),\r\n+    checkNetwork: React.PropTypes.bool\r\n+    networkAvailable: React.PropTypes.bool\r\n };\r\n \r\n \r\n@@ -239,5 +242,7 @@\r\n     activityIndicatorProps: {\r\n         style: { backgroundColor: 'transparent', flex: 1 }\r\n     },\r\n-    useQueryParamsInCacheKey: false // bc\r\n+    useQueryParamsInCacheKey: false, // bc\r\n+    checkNetwork: true,\r\n+    networkAvailable: false\r\n };\r\n\\ No newline at end of file\r\n\r\n```"}}
{"actor":{"display_login":"jayesbe"}}