smart load react native image resource both from apk(ipa) and jsbundle Dir.
Smartassets change the react native image load logic by hook defaultAsset method.
Smartassets let your app can load image form apk(ipa in iOS case) and filesystem with smart choose.
$ npm install --save react-native-smartassets
$ react-native link react-native-smartassets
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-smartassets
and add RNSmartassets.xcodeproj
libRNSmartassets.a
to your project's Build Phases
➜ Link Binary With Libraries
Cmd+R
)<android/app/src/main/java/[...]/MainActivity.java
import com.smallnew.smartassets.RNSmartassetsPackage;
to the imports at the top of the filenew RNSmartassetsPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-smartassets'
project(':react-native-smartassets').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-smartassets/android')
android/app/build.gradle
:
compile project(':react-native-smartassets')
import {SmartAssets} from 'react-native-smartassets';
SmartAssets.initSmartAssets();
SmartAssets.setiOSRelateMainBundlePath(youOriginJsBundlePath);//optional