【文件属性】:
文件名称:react-tiniest-router:React最小的路由器,带有钩子
文件大小:192KB
文件格式:ZIP
更新时间:2021-03-02 03:23:47
TypeScript
:mouse: 最细的路由器
在您确实需要简单路由器的时代。 基于和 。
用法
编写路线对象。
const routes = {
home : {
id : 'home' ,
path : '/' ,
} ,
about : {
id : 'about' ,
path : '/about' ,
} ,
gallery : {
id : 'gallery' ,
path : '/gallery/:imageId' ,
} ,
}
使用Router组件包装您的应用
< Router xss=removed>
< App>
< / Router >
使用useRouter使用路由器
使用goTo功能导航到路线
使用isRoute函数检查路由当前是否处于活动状态
const Root = ( ) =>
【文件预览】:
react-tiniest-router-master
----.gitignore(109B)
----package.json(964B)
----src()
--------use-router.ts(172B)
--------router-context.ts(148B)
--------index.ts(127B)
--------utils.ts(1KB)
--------Router.tsx(2KB)
--------types.ts(546B)
----tsconfig.json(738B)
----README.md(3KB)
----example()
--------package.json(571B)
--------tsconfig.json(458B)
--------index.html(301B)
--------.npmignore(24B)
--------index.tsx(1KB)
--------yarn.lock(219KB)
----yarn.lock(265KB)