Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
react-native-flex-image
Advanced tools
A flexible-width component for React Native using aspectRatio
Note: Only for React Native version >= 0.40.0
$ yarn add react-native-flex-image
-- or --
$ npm install react-native-flex-image --save
Use <FlexImage>
to display an image sized to the full-width of its parent while maintaining the correct ratio, without explicitly defining the width and height. FlexImage supports local images (asset) and remote images (uri).
Also supports loading indicator for remote images.
Expo demo: https://exp.host/@kfox/react-native-flex-image
import FlexImage from 'react-native-flex-image';
function App() {
return (
<View style={{flex: 1}}>
<FlexImage
source={{
uri: 'image source uri',
}}
/>
</View>
);
}
import FlexImage from 'react-native-flex-image';
function App() {
return (
<View style={{flex: 1}}>
<FlexImage source={require('./assets/react-logo.png')} />
</View>
);
}
import FlexImage from 'react-native-flex-image';
function App() {
return (
<View style={{flex: 1}}>
<FlexImage
source={{
uri: 'https://example.com/path/to/my/image',
}}
onPress={() => {
let {imageClickCount} = this.state;
this.setState({
imageClickCount: imageClickCount + 1,
});
}}
/>
</View>
);
}
import FlexImage from 'react-native-flex-image';
function App() {
return (
<View style={{flex: 1}}>
<FlexImage
source={{
uri: 'image source uri',
}}
loadingComponent={<ActivityIndicator size="large" color="red" />}
/>
</View>
);
}
import FlexImage from 'react-native-flex-image';
function App() {
return (
<View style={{flex: 1}}>
<FlexImage
source={{
uri: 'image source uri',
}}
thumbnail={{uri: 'thumbnail image source uri'}}
loadingMethod="progressive"
/>
</View>
);
}
Note: Other properties will be passed down to underlying image component.
Prop | Type | Description | Default |
---|---|---|---|
source | required | source of the image | None |
onPress | optional | onPress event when user clicking the image | null |
style | optional | custom style for the image container | null |
loadingComponent | optional | custom loading indicator when render the image | <ActivityIndicator animating={true} size="large" /> |
thumbnail | optional | source of the thumbnail | None |
loadingMethod | optional | enum for select loading method, using indicator or progressive | indicator |
errorComponent | optional | custom error component when fail displaying the image | null |
MIT License. ©2017 - current, KodeFox, Inc.
FAQs
A flexible-width component for React Native using `aspectRatio`
The npm package react-native-flex-image receives a total of 7,930 weekly downloads. As such, react-native-flex-image popularity was classified as popular.
We found that react-native-flex-image demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.