Setting up
/ / MAC development platform, xcode ios debugging tools, JS version installed > official reference: https://www.reactnative.cn/docs/getting-started.html > steps: NPX react-native init rnApp CD rnApp yarn ios > https://github.com/ant-design/antd-mobile-samples/tree/master/create-react-native-app > steps: Yarn add -g create-react-native app create-react-native app rnApp CD rnApp yarn start // The installation is complete Nativ yarn add @ant-design/react-nativ yarn add @ant-design/react-native Yarn react-native link @ant-design/ ICONS react-native // Install yarn add react-native-cli -g > Install pod-install CD rnApp/ios NPX pod-install > Last CD rnApp(run two terminals) one yarn ios one yarn Start // If no error is reported, the project is running properly, the first run will be slow.Copy the code
Could not find “podfile. lock”,Did you run “pod install” in ios directory?
Brew install cocoapods and install pod-install on cocoapodsCopy the code
Error Failed to build iOS project. We ran “xcodebuild” command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by ope
Rm -rf node_modules && yarn cache clean yarn install rm -rf ~/. Rncache Then run yarn ios yarn start againCopy the code
Added the SRC project directory
├─ SRC # Code Directory │ ├─ Parts # ├─ Models # Models │ ├─ Pages # ├─ Routes # ├─ ├─ exercises, ├─ exercises, exercises, exercises, exercises, exercises, exercises, exercises, exercisesCopy the code
Change the address of the import directory of the app.js entry file
Import {AppRegistry} from 'react-native' in index.js; import App from './src/App'; Import {name as appName} from './app.json'; AppRegistry.registerComponent(appName, () => App);Copy the code
Manage data using DVA status
App.js import indexModel from './models/indexModel'; app.js import indexModel from './models/indexModel'; import demo from './models/demo'; import { Provider } from 'react-redux'; import { create } from 'dva-core'; import Home from './pages/Home'; const models = [indexModel,demo]; const app = create(); / Create a DVA instance that can pass configuration parameters. https://dvajs.com/api/#app-dva-opts models.foreach ((o) => {// Load models object app.model(o); }); app.start(); // Instantiate const store = app._store; Const App = () => {return (<Provider> store={store}> <! --> <Home/> </Provider>)} export default App; Export default {namespace: 'indexModel', state: {name:'123'}, effects: { }, reducers: { updateState(state, { payload }) { return { ... state, ... payload }; }},} > Home component import React from 'React '; import { View, Text, Button } from 'react-native'; import {connect} from 'react-redux'; Const Home = (props) => {return (<View> <Text> hello :{props. Name}</Text> <Text /> </View>)} export default connect(({indexModel,demo}) => {return {name: indexModel.name, abc:demo.abc, }; })(Home);Copy the code
Unified routing configuration and unified request blocking, waiting for updates…