Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/markzhai/react-native-preloader
React Native Pre-loader for Android.
https://github.com/markzhai/react-native-preloader
Last synced: about 1 month ago
JSON representation
React Native Pre-loader for Android.
- Host: GitHub
- URL: https://github.com/markzhai/react-native-preloader
- Owner: markzhai
- License: apache-2.0
- Created: 2016-08-20T05:56:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-01T03:16:55.000Z (over 8 years ago)
- Last Synced: 2024-04-09T21:38:13.286Z (9 months ago)
- Language: Java
- Homepage: http://blog.zhaiyifan.cn/2016/08/20/react-native-0-31-preload-optimization/
- Size: 1.45 MB
- Stars: 53
- Watchers: 6
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-preloader
React Native Pre-loader for Android.
During development of React Native on Android hybrid app, we can find that even in a release package with js bundle in assets, the first startup of the entry React Native Activity can still cost over 1 second, which severely effects user experience. What's more, if we exit the React Activity, and enter again, it still costs that much time. Holy shit!
This library is to solve the problem, and let you load the React Native Activity in milliseconds, painlessly.
Support React Native versions:
- 0.30
- 0.31
- 0.32May also run on other versions, but I have not checked that.
Effects on our application:
![screenshot](screenshot.gif "screenshot")
# TODO
- Check bundle update support.
# Run demo
In order to run demo, your should have react-native installed, then
```bash
# install dependencies according to package.json
npm install# package js files into bundle, which will be under assets directory.
sh package.sh
```# Usage
```groovy
dependencies {
compile "com.github.markzhai:react-native-preloader:0.32.0"
}
```In the activity which you want to pre-load ReactActivity:
```java
ReactPreLoader.init(this, DemoReactActivity.reactInfo);
```Make your ReactActivity extends the one in the library:
```java
public class DemoReactActivity extends MrReactActivity {public static final ReactInfo reactInfo = new ReactInfo("HelloWorld", null);
@Override
protected String getMainComponentName() {
return reactInfo.getMainComponentName();
}@Override
public ReactInfo getReactInfo() {
return reactInfo;
}
}
```# How it works
See `ReactPreLoader` and `MrReactActivity`'s `onCreate`.
# License
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.