创建一个typescript项目
npx react-native init ywh --template react-native-template-typescript
导入库
整合
方便一键安装,以下仅是本人常用的组件,可以按需增减
yarn add react-native-webview @react-native-async-storage/async-storage react-native-animatable react-native-paper react-native-root-siblings react-native-root-toast base-64 @react-navigation/native react-native-screens react-native-safe-area-context @react-navigation/native-stack @react-navigation/bottom-tabs react-native-reanimated react-native-gesture-handler @react-navigation/drawer @react-navigation/material-bottom-tabs react-native-paper react-native-vector-icons react-native-pager-view react-native-animatable react-native-linear-gradient @ant-design/icons-react-native
需要手动配置的库
大部分时候iOS端只要pod install就行了,而安卓需要手动修改一些代码或者配置文件。我把需要配置的地方列出来,防止遗忘。
react-navigation配置方法见:https://reactnavigation.org/docs/getting-started/
react-native-reanimatedhttps://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ 这里有一个小坑,设置完成了后,要执行一下
yarn start --reset-cache
不然不会生效。
react-native-vector-iconshttps://github.com/oblador/react-native-vector-icons#android
@ant-design/icons-react-nativehttps://blog.csdn.net/lxyoucan/article/details/108334465
详细 WebViewreact-native-webview
提供WebView
在本机视图中呈现 Web 内容的组件。
expo install react-native-webview
https://docs.expo.io/versions/latest/sdk/webview/
AsyncStorage一个异步的、未加密的、持久的、键值存储 API。
expo install @react-native-async-storage/async-storage
https://docs.expo.io/versions/latest/sdk/async-storage/
react-native-animatableReact Native 的声明式过渡和动画
yarn add react-native-animatable
https://github.com/oblador/react-native-animatable
react-native-paperyarn add react-native-paper
react-native-root-siblings
yarn add react-native-root-siblings
@ant-design/react-native
expo install @ant-design/react-native
react-native-root-toast
yarn add react-native-root-toast
base-64
yarn add base-64
react navigation
yarn add @react-navigation/native
expo install react-native-screens react-native-safe-area-context
yarn add @react-navigation/native-stack
yarn add @react-navigation/bottom-tabs
expo install react-native-reanimated
expo install react-native-gesture-handler
yarn add @react-navigation/drawer
expo-linking
expo install expo-linking
expo-linear-gradient
expo install expo-linear-gradient
react-native-pager-view
yarn add react-native-pager-view
Material Bottom Tabs Navigator
yarn add @react-navigation/material-bottom-tabs react-native-paper react-native-vector-icons
ant
yarn add @react-native-community/segmented-control
yarn add @react-native-community/cameraroll
yarn add @react-native-picker/picker
React Native 篇
react-native-animatable
React Native 的声明式过渡和动画
yarn add react-native-animatable
https://github.com/oblador/react-native-animatable
yarn add react-native-linear-gradient
https://github.com/react-native-linear-gradient/react-native-linear-gradient