Skip to content

Commit 549e1ca

Browse files
committed
docs: 修改首页 react-native-template文档
1 parent 1b9ba3b commit 549e1ca

File tree

4 files changed

+40
-55
lines changed

4 files changed

+40
-55
lines changed

website/src/component/Header/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function Header(props: HeaderProps) {
3636
<NavLink to="/home">首页</NavLink>
3737
<NavLink to="/docs">文档</NavLink>
3838
<NavLink to="/components">RN组件</NavLink>
39-
<a target="__blank" href="https://pushy.reactnative.cn/">
39+
<a target="__blank" href="https://microsoft.github.io/code-push/">
4040
热更新
4141
</a>
4242
<a target="__blank" href="https://github.com/uiwjs/react-native-uiw/issues">

website/src/pages/docs/react-native-template/menu-route/README.md

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,35 +73,22 @@ iOS上后退按钮使用的标题字符串。默认为前一个场景的headerTi
7373
## 路由跳转
7474

7575
```js
76-
import {View} from 'react-native';
77-
import { List, Icon} from '@uiw/react-native';
78-
79-
<List
80-
flat={true}
81-
data={[
82-
{title: '企业开票'},
83-
{title: '我的熟车'},
84-
{title: '设置', onPress: () => navigation.navigate('MyHomeSetting')},
85-
{title: '退出登录', onPress: () => navigation.replace('SignIn')},
86-
]}
87-
renderItem={({item, index}) => {
88-
return (
89-
<List.Item
90-
key={index}
91-
extra={<Icon name="right" fill="#abb0b5" size={14} />}
92-
size="large"
93-
paddingLeft={15}
94-
style={{borderBottomWidth: 0}}
95-
onPress={item.onPress || null}>
96-
<View>
97-
<Text>{item.title}</Text>
98-
</View>
99-
</List.Item>
100-
);
101-
}}
102-
/>
103-
```
76+
import React from 'react';
77+
import { Button } from '@uiw/react-native';
10478

79+
const Demo = ({ navigation }) => {
10580

81+
return (
82+
<Button
83+
textStyle={{ fontSize: 16, fontWeight: '200' }}
84+
bordered={false}
85+
color="#BFBFBF"
86+
onPress={() => navigation.replace('SignIn')}>
87+
跳转
88+
</Button>
89+
);
90+
}
91+
92+
```
10693

10794

website/src/pages/docs/react-native-template/mock-data/README.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package.json
1919

2020
> 在/mocker/user.mock.js目录下进行mock数据编写,比如:
2121
22-
```ts
22+
```js
2323
module.exports = {
2424
'POST /api/login': (req, res) => {
2525
let {username, password} = req.body;
@@ -41,55 +41,55 @@ module.exports = {
4141

4242
### 二、界面渲染
4343

44-
```
45-
import React, { useState } from 'react';
44+
```js
45+
import React, { useState } from 'react';
4646
import { connect } from 'react-redux';
47-
import AsyncStorage from '@react-native-async-storage/async-storage';
4847
import { Button } from '@uiw/react-native';
49-
import Global from '../../global';
50-
import { useLogin } from '../../hooks/users'
48+
import { login } from '../../hooks/users'
49+
50+
const Demo = ({ update }) => {
51+
const [store, setStore] = useState({
52+
formData: {
53+
username: 'admin',
54+
password: 'admin!',
55+
},
56+
})
5157

52-
const Dome = ({ update }) => {
53-
54-
const { mutate, isLoading } = useLogin({
58+
const { mutate, isLoading } = login({
5559
update,
5660
formData,
5761
})
5862

59-
const loginIn = () => mutate?.({ ...formData })
60-
6163
return (
6264
<Button
6365
textStyle={{ fontSize: 16, fontWeight: '200' }}
6466
bordered={false}
6567
color="#BFBFBF"
6668
loading={isLoading}
6769
disabled={isLoading}
68-
onPress={loginIn}>
70+
onPress={() => mutate?.({ ...formData })}>
6971
Sign In
7072
</Button>
7173
);
7274
}
7375

7476
export default connect(
75-
({ }) => ({}),
77+
({}) => ({}),
7678
({ global }) => ({
7779
update: global.update
7880
}),
79-
)(Dome);
81+
)(Demo);
8082

8183
```
8284
### 三、使用react-query调用api
8385
[react-query](https://tanstack.com/query/latest) 更详细的使用,请参照官方文档
8486
85-
```
86-
import { Alert } from 'react-native';
87-
import AsyncStorage from '@react-native-async-storage/async-storage';
87+
```js
8888
import { userLogin } from '../services/users';
8989
import { useQuery, useMutation } from 'react-query'
9090

9191
// 登录
92-
export const useLogin = ({ config = {}, update, formData, remember }) => {
92+
export const login = ({ config = {}, update, formData }) => {
9393
const mutation = useMutation({
9494
mutationFn: userLogin,
9595
onSuccess: async (data) => {
@@ -107,14 +107,12 @@ export const useLogin = ({ config = {}, update, formData, remember }) => {
107107
108108
> 配合系统封装的request进行mock数据请求。如需区分是mock数据,还是真实后端数据,调用真实数据时,注释mocker数据配置即可
109109
110-
```ts
111-
import { request } from "@uiw-admin/utils"
110+
```js
111+
import { fetch } from '../utils';
112112

113113
export async function userLogin(params) {
114-
return fetch('/api/login', {
115-
body: params,
116-
});
117-
}
114+
return fetch('/api/login', { body: params });
115+
}
118116
```
119117
120118
注:mock功能只推荐在开发模式下开启。

website/src/pages/docs/react-native-template/new-page/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
```
3737

3838
为了更好的演示,我们初始化NewPage/index.js的内容如下:
39-
```jsx
39+
```js
4040
import React, {Component} from 'react';
4141
import {View, Text, SafeAreaView} from 'react-native';
4242

@@ -55,7 +55,7 @@ export default class MyNewPage extends Component {
5555
将文件加入菜单和路由
5656

5757
在 src / routes 下homeTab.js中使用 component 配置我们页面到路由中
58-
```jsx
58+
```js
5959
import MyNewPage from '../pages/NewPage';
6060

6161
export const stackPageData = [

0 commit comments

Comments
 (0)