上QQ阅读APP看书,第一时间看更新
Adding dependencies
For this project, we will use several npm modules to save development time and put the focus on the functional aspects of the RSS reader itself, rather than dealing with custom state management frameworks, custom UI, or data processing. For these matters, we will use the following package.json file:
{
"name":"rssReader",
"version":"0.0.1",
"private":true,
"scripts":{
"start":"node node_modules/react-native/local-cli/cli.js start",
"test":"jest"
},
"dependencies":{
"mobx":"^3.1.9",
"mobx-react":"^4.1.8",
"native-base":"^2.1.3",
"react":"16.0.0-beta.5",
"react-native": "0.49.3",
"react-native-vector-icons":"^4.1.1",
"react-navigation":"^1.0.0-beta.9",
"simple-xml2json":"^1.2.3"
},
"devDependencies":{
"babel-jest":"20.0.0",
"babel-plugin-transform-decorators-legacy":"^1.3.4",
"babel-preset-react-native":"1.9.1",
"babel-preset-react-native-stage-0":"^1.0.1",
"jest":"20.0.0",
"react-test-renderer":"16.0.0-alpha.6"
},
"jest":{
"preset":"react-native"
}
}
As can be seen in this file, we will be using the following npm modules together with the standard React Native's modules:
- mobx: This is the state management library we will be using
- mobx-react: This is the official React bindings for MobX
- native-base: As we did in the previous chapter, we will use NativeBase's UI library
- react-native-vector-icons: NativeBase requires this module to display graphic icons
- react-navigation: We will use the React Native's community navigation library again
- simple-xml2json: A lightweight library to convert XML (the standard format for RSS feeds) into JSON to easily manage the RSS data within our code
Having this package.json file, we can run the following command (in the root folder of our project) to finish the installation:
npm install
Once npm finishes installing all dependencies, we can start our app in the iOS simulator:
react-native run-ios
Or in the Android emulator:
react-native run-android