Skip to content

tuantvk/react-native-copy-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

react-native-copy-image

Copy images for Android and iOS in React Native, use image from local project.

Install

  • Create folder scripts/ from root project.
mkdir scripts
  • Clone project:
cd scripts
git clone https://github.com/tuantvk/react-native-copy-image.git;
cd react-native-copy-image;rm -rf .git;

Usage

Make sure folder images in rootProject/assets/images/

Add script in package.json

"scripts": {
    ....
    "copy-image": "bash scripts/react-native-copy-image/copy_image.sh" // add here
}

Finally, from root project run:

yarn run copy-image

# or
# npm run copy-image

Check all images in path:

  • Android: android/app/src/main/res/drawable/
  • iOS: ios/[AppName]/Images.xcassets

Note:

Rebuild app for update resource !

Warning

Images has format to snake_case

Ex: Apple.png -> apple.png | Apple Computer.jpg -> apple_computer.jpg

Example

This is example for image name apple.png

import React from 'react';
import { View, Image } from 'react-native';


const Example = () => (
    <View>
        <Image
            source={{ uri: 'apple' }}
            style={{ width: 50, height: 50 }}
        />
    </View>
);

export default Example;

LICENSE

MIT

About

Copy images for Android and iOS in React Native, use image from local project

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages