From acbb3fce1d1f3875ca07bdede71c62625ac45ea8 Mon Sep 17 00:00:00 2001 From: wangyizhou Date: Tue, 27 Feb 2024 16:27:04 +0800 Subject: [PATCH] =?UTF-8?q?[Issues:=20#I945FZ]=20=E6=B7=BB=E5=8A=A0react-r?= =?UTF-8?q?outer-dom=E6=8C=87=E5=AF=BC=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1224/react-router-dom.md | 107 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 1224/react-router-dom.md diff --git a/1224/react-router-dom.md b/1224/react-router-dom.md new file mode 100644 index 00000000..66b5ac2e --- /dev/null +++ b/1224/react-router-dom.md @@ -0,0 +1,107 @@ +> 模板版本:v0.1.3 + +

+

react-router-dom

+

+

+ + Supported platforms + + + License + +

+ + + +> [!tip] [Github 地址](https://github.com/remix-run/react-router) + +## 安装与使用 + +进入到工程目录并输入以下命令: + + + +#### **npm** + +```bash +npm i react-router-dom@6.22.1 +``` + +#### **yarn** + +```bash +yarn add react-router-dom@6.22.1 +``` + + + +下面的代码展示了这个库的基本使用场景: + +```tsx +import React from 'react'; +import { ScrollView } from 'react-native'; +import { + Route, Routes, + MemoryRouter as Router +} from 'react-router-dom'; + +const DomDemo = () => { + const initialEntries = [ + "/", + { pathname: "/login", state: { stateTest: "stateTestContent" } }, + { pathname: "/detail", state: { stateTest: "stateTestContent" } }, + "/index3", + ]; + return ( + + + + } > + } /> + } /> + + } /> + } /> + } /> + + + + ); +}; + +export default DomDemo; +``` + +## 约束与限制 + +### 兼容性 + +本文档内容基于以下版本验证通过: + +1. RNOH:0.72.13; SDK:HarmonyOS NEXT Developer Preview1; IDE:DevEco Studio 4.1.3.500; ROM:2.0.0.59; + +## 属性 + +> [!tip] "Platform"列表示该属性在原三方库上支持的平台。 + +> [!tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 + +以下属性已验证,详情见 [react-router-dom源库地址](https://github.com/remix-run/react-router) + +**Hooks** + +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ----------- | ------------------------------------------------------------ | -------- | -------- | -------- | ----------------- | +| useLocation | This hook returns the current [`location`](https://reactrouter.com/en/main/utils/location) object. This can be useful if you'd like to perform some side effect whenever the current location changes. | Function | NO | All | YES | +| useNavigate | The `useNavigate` hook returns a function that lets you navigate programmatically, for example in an effect: | Function | NO | All | YES | +| useOutlet | Returns the element for the child route at this level of the route hierarchy. This hook is used internally by < Outlet > to render child routes. | Function | NO | All | YES | +| useRoutes | The useRoutes hook is the functional equivalent of < Routes >, but it uses JavaScript objects instead of < Route > elements to define your routes. These objects have the same properties as normal < Route > elements, but they don't require JSX. | Function | NO | All | YES | + +## 遗留问题 + +## 其他 + +## 开源协议 + +本项目基于 [The MIT License (MIT)](https://github.com/remix-run/react-router/blob/main/LICENSE.md) ,请自由地享受和参与开源。 \ No newline at end of file -- Gitee