Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Merges in both debugging and ensuring fetch is cancelled #22

wants to merge 7 commits into from

Conversation

RobertFischer
Copy link

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

Copy link
Owner

@seekshiva seekshiva left a 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");
Copy link
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?

"prop-types": "^15.6.2"
},
"devDependencies": {
"supports-color": "^5.4.0"
Copy link
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?

const props = this.props;
const { svgContent } = this.state;
if (svgContent) {
const props = this.props || {};
Copy link
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

const { svgContent } = this.state;
if (svgContent) {
const props = this.props || {};
const { svgContent } = this.state || {};
Copy link
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.

.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
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?

@@ -0,0 +1,2 @@
yarn.lock
Copy link
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.

None yet

2 participants