Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render() {
// Force complete re-render.
const key = uuid()
// Busting image cache.
const bust = `?bust=${key}`
// Preload images.
FastImage.preload([
{
uri: 'https://facebook.github.io/react/img/logo_og.png',
headers: { Authorization: 'someAuthToken' },
},
{
uri: 'https://facebook.github.io/react/img/logo_og.png',
headers: { Authorization: 'someAuthToken' },
},
])
return (
const withUniqueTokenFamiliesSection = (language, uniqueTokens, data) => {
// TODO preload elsewhere?
if (!isPreloadComplete) {
const imagesToPreload = sortImagesToPreload(
data.map(buildImagesToPreloadArray)
);
isPreloadComplete = !!imagesToPreload.length;
FastImage.preload(imagesToPreload);
}
return {
collectibles: true,
data,
header: {
title: lang.t('account.tab_collectibles'),
totalItems: uniqueTokens.length,
totalValue: '',
},
name: 'collectibles',
renderItem: tokenFamilyItem,
type: 'big',
};
};
.then(res => {
if (res.info().status === 200) {
FastImage.preload([{ uri: appData.featureGraphic }]);
} else {
appData.featureGraphic = null;
}
})
.catch(err => console.log(err));
dataProvider: new DataProvider((r1, r2) => r1 !== r2).cloneWithRows(this.props.allAssets.concat(this.props.uniqueTokens)),
openCards: [],
};
const imageTokens = [];
this.props.uniqueTokens.forEach(family => {
family.data.forEach(token => {
if (token.image_thumbnail_url) {
imageTokens.push({
id: token.id,
uri: token.image_thumbnail_url,
});
}
});
});
FastImage.preload(imageTokens);
this._layoutProvider = new LayoutProvider((i) => {
if (i < this.props.allAssets.length - 1) {
return 'COIN_ROW';
} if (i === this.props.allAssets.length - 1) {
return 'COIN_ROW_LAST';
}
if (this.state.openCards[i - this.props.allAssets.length]) {
return {
size: this.props.uniqueTokens[i - this.props.allAssets.length].data.length + 1,
type: 'COLLECTIBLE_ROW',
};
}
return 'COLLECTIBLE_ROW_CLOSED';
}, (type, dim) => {
if (type === 'COIN_ROW') {
async fetch() {
const { url } = this.props;
if (!url || this.state.title || this.state.image) return;
this.setState({ loading: true });
const { title, image } = await fetchMetadata(url);
if (this.dead) return;
if (image && typeof image.url === 'string' && this.showThumbnail) {
const res = await FastImage.preload([{ uri: image.url }]);
}
if (this.dead) return;
this.setState({
title,
image,
loading: false,
});
}
preload = () => {
FastImage.preload([{ uri: this.state.url }])
}
preload = () => {
FastImage.preload([{ uri: this.state.url }])
}