Skip to content

Merges in both debugging and ensuring fetch is cancelled#22

Open
RobertFischer wants to merge 7 commits into
seekshiva:masterfrom
BeeWell:rcf/ensure-fetch-cancelled-with-debug
Open

Merges in both debugging and ensuring fetch is cancelled#22
RobertFischer wants to merge 7 commits into
seekshiva:masterfrom
BeeWell:rcf/ensure-fetch-cancelled-with-debug

Conversation

@RobertFischer

Copy link
Copy Markdown

#20 and #21 wrapped up into one nice package. :)

@seekshiva seekshiva left a comment

Copy link
Copy Markdown
Owner

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?

Comment thread SvgImage.js
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");

Copy link
Copy Markdown
Owner

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?

Comment thread package.json
"prop-types": "^15.6.2"
},
"devDependencies": {
"supports-color": "^5.4.0"

Copy link
Copy Markdown
Owner

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?

Comment thread SvgImage.js
const props = this.props;
const { svgContent } = this.state;
if (svgContent) {
const props = this.props || {};

Copy link
Copy Markdown
Owner

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

Comment thread SvgImage.js
const { svgContent } = this.state;
if (svgContent) {
const props = this.props || {};
const { svgContent } = this.state || {};

Copy link
Copy Markdown
Owner

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.

Comment thread SvgImage.js
.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

Copy link
Copy Markdown
Owner

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?

Comment thread .gitignore
@@ -0,0 +1,2 @@
yarn.lock

Copy link
Copy Markdown
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants