diff --git a/docs/react-native.md b/docs/react-native.md index cb3dd41..34b08fc 100644 --- a/docs/react-native.md +++ b/docs/react-native.md @@ -22,7 +22,7 @@ $ ruby --version # ruby 2.7.5 ``` -注意: macOS 12.5.1 附带了 Ruby 2.6.8,这不是 React Native 所要求的,React Native 70+ 需要 Ruby 2.7.5,可以使用下面工具切换版本: +注意: macOS 12.5.1 附带了 Ruby **2.6.8**,这不是 React Native 所要求的,React Native 70+ 需要 Ruby **2.7.5**,可以使用下面工具切换版本: - [rbenv](https://github.com/rbenv/rbenv) - [RVM](https://rvm.io/) @@ -162,19 +162,10 @@ export default function ViewExample() { return ( - - - Hello World! - + /> ); }; ``` @@ -185,9 +176,10 @@ export default function ViewExample() { ```jsx import React from 'react'; -import { Text, StyleSheet } from 'react-native'; +import { Text } from 'react-native'; +import { StyleSheet } from 'react-native'; -export default function BoldAndBeautiful() { +export default function BoldBeautiful() { return ( 我是粗体 @@ -197,7 +189,6 @@ export default function BoldAndBeautiful() { ); }; - const styles = StyleSheet.create({ baseText: { fontWeight: 'bold' }, innerText: { color: 'red' } @@ -212,25 +203,21 @@ const styles = StyleSheet.create({ import React from "react"; import { SafeAreaView, StyleSheet, TextInput } from "react-native"; -const UselessTextInput = () => { - const [text, onChangeText] = React.useState("Useless Text"); +export default function UseTextInput() { + const [ + text, onChangeText + ] = React.useState("Useless Text"); return ( ); }; - -const styles = StyleSheet.create({ - input: { height: 40, padding: 10, }, -}); - -export default UselessTextInput; ``` + 用于通过键盘将文本输入应用程序的组件 @@ -324,7 +311,9 @@ import { StyleSheet, Text, View } from "react-native"; export const App = () => ( - React Native + + React Native + ); @@ -340,6 +329,7 @@ const styles = StyleSheet.create({ } }); ``` + 提供类似于 CSS 样式表的抽象层 @@ -350,6 +340,8 @@ const styles = StyleSheet.create({ ### Button ```jsx +import { Button } from "react-native"; +