-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merges in both debugging and ensuring fetch is cancelled #22
base: master
Are you sure you want to change the base?
Merges in both debugging and ensuring fetch is cancelled #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Robert,
This is a really good PR. Thanks.
Can you take a look at these review change requests?
import { View, WebView } from 'react-native'; | ||
import { View, WebView, StyleSheet } from 'react-native'; | ||
const fetchingDebug = require("debug")("react-native-remote-svg:SvgImage:fetch"); | ||
const fetchResultDebug = require("debug")("react-native-remote-svg:SvgImage:fetch:result"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, it looks like you used the debug
package to debug this issue. Does it make sense to commit it onto master?
"prop-types": "^15.6.2" | ||
}, | ||
"devDependencies": { | ||
"supports-color": "^5.4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package doesn't seem to be used anywhere. Was this required for the use of debug
package? Can this be removed?
const props = this.props; | ||
const { svgContent } = this.state; | ||
if (svgContent) { | ||
const props = this.props || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.props should always be an object in react. Have you seen any situation where it might be falsy? It shouldn't be
const { svgContent } = this.state; | ||
if (svgContent) { | ||
const props = this.props || {}; | ||
const { svgContent } = this.state || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are initializing state
for this component. So this || {}
wouldn't be necessary.
.call("text") | ||
.then(text => this.setState({ svgContent: text })) | ||
.catch(e => console.error(`Error fetching SVG URI: ${e.message||e}`, {uri, e})) | ||
.return((previousFetch && previousFetch.isPending()) ? previousFetch : null) // Ensure we resolve/cancel previous fetch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we cancel the previousFetch if the uri has changed?
@@ -0,0 +1,2 @@ | |||
yarn.lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is actually recommended for yarn.lock to be committed, since multiple people developing the project would all be on the same locked version.
#20 and #21 wrapped up into one nice package. :)