-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(rejection): 🔨Optimize error handling from
Image.getSize
Still reject errors from `Image.getSize`. Catch errors in `updateImageHeight`. Not caching the wrong image size.
- Loading branch information
Showing
4 changed files
with
33 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,41 @@ | ||
import React, { Component } from 'react'; | ||
import AutoHeightImage from 'react-native-auto-height-image'; | ||
import { StyleSheet, Text, View } from 'react-native'; | ||
import { StyleSheet, Text, ScrollView } from 'react-native'; | ||
|
||
export default class App extends Component { | ||
render() { | ||
return ( | ||
<View style={styles.container}> | ||
<ScrollView style={styles.scrollViewContainer} contentContainerStyle={styles.scrollViewContentContainer}> | ||
<Text>Basic example</Text> | ||
<AutoHeightImage | ||
width={100} | ||
imageURL={'http://placehold.it/350x150'} | ||
/> | ||
<Text>Basic example</Text> | ||
<AutoHeightImage | ||
width={200} | ||
imageURL={'http://placehold.it/350x150'} | ||
/> | ||
<Text>Wrong imageURL</Text> | ||
<AutoHeightImage | ||
width={100} | ||
imageURL={'abcdefg'} | ||
imageURL={'https://vivaxy.github.io/404'} | ||
onError={(error) => { | ||
console.log(error); | ||
console.log('----- onError', error); | ||
}} | ||
/> | ||
</View> | ||
</ScrollView> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
scrollViewContainer: { | ||
flex: 1, | ||
backgroundColor: '#fff', | ||
marginTop: 20, | ||
}, | ||
scrollViewContentContainer: { | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export const NOOP = () => {}; | ||
export const NOOP = () => { | ||
}; | ||
export const DEFAULT_WIDTH = 0; | ||
export const DEFAULT_HEIGHT = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters