Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/native-router/react

A route close to the native experience for react.
https://github.com/native-router/react

async data-fetching react react-router router tiny

Last synced: about 1 month ago
JSON representation

A route close to the native experience for react.

Awesome Lists containing this project

README

        

[![npm](https://img.shields.io/npm/v/@native-router/react.svg)](https://www.npmjs.com/package/@native-router/react)
[![Build Status](https://github.com/native-router/react/actions/workflows/ci.yml/badge.svg)](https://github.com/native-router/react/actions)
[![codecov](https://codecov.io/gh/native-router/react/graph/badge.svg?token=QIXC6HJH6Z)](https://codecov.io/gh/native-router/react)
[![install size](https://packagephobia.now.sh/badge?p=@native-router/react)](https://packagephobia.now.sh/result?p=@native-router/react)

# Native Router React

> 接近原生体验的 React 路由库。

[English](./README.md) | 简体中文

## 特性

- 异步导航
- 可取消
- 页面视图和数据并发拉取
- 链接页面预加载及预览
- 轻量小巧,Tree-Shaking 友好
- 支持 TreeShaking

## 安装

```bash
npm i @native-router/react
```

## 使用

```tsx
import {View, HistoryRouter as Router} from '@native-router/react';
import Loading from '@/components/Loading';
import RouterError from '@/components/RouterError';
import * as userService from '@/services/user';

export default function App() {
return (
import('./Layout'),
children: [
{
path: '/',
component: () => import('./Home')
},
{
path: '/users',
component: () => import('./UserList'),
data: userService.fetchList
},
{
path: '/users/:id',
component: () => import('./UserProfile'),
data: ({id}) => userService.fetchById(+id)
},
{
path: '/help',
component: () => import('./Help')
},
{
path: '/about',
component: () => import('./About')
}
]
}}
baseUrl="/demos"
errorHandler={(e) => }
>



);
}

```

查看 [完整示例](/demos/)。

## 文档

[API](https://native-router.github.io/react/modules.html)