rxdb-react
React 框架集成库,为 React 应用提供 RxDB 支持。基于 React Hooks 实现响应式数据流。
功能特性
- React Hooks 集成: 使用 useRxdb、useCollection 等 Hooks
- 组件库: 提供数据展示、编辑、表单等常用组件
- TypeScript 支持: 完整的类型定义
- 响应式更新: 数据变化自动触发组件重渲染
何时使用
- 构建 React 应用并需要本地优先数据库
- 需要响应式数据流与 React Hooks 无缝集成
- 需要离线优先的 React 应用
安装
npm install @aiao/rxdb @aiao/rxdb-react
# 或
pnpm add @aiao/rxdb @aiao/rxdb-react
使用
import { RxdbProvider } from '@aiao/rxdb-react';
function App() {
return (
<RxdbProvider>
<YourApp />
</RxdbProvider>
);
}
完整示例
参考 dev-rxdb-react 中的完整集成示例。
Fileoverview
RxDB React 集成包 提供 RxDB 数据库的 React Hooks 接口
Interfaces
| Interface | Description |
|---|---|
| InfiniteScrollResource | - |
| RxDBResource | - |
Variables
| Variable | Description |
|---|---|
| RxDBProvider | - |
| useRxDB | - |
Functions
| Function | Description |
|---|---|
| makeRxDBProvider | RxDB 依赖注入 |
| useCount | Count entities matching the criteria |
| useCountAncestors | Count ancestor entities in a tree structure |
| useCountDescendants | Count descendant entities in a tree structure |
| useCountNeighbors | Count neighbor entities in a graph structure |
| useFind | Find multiple entities matching the criteria |
| useFindAll | Find all entities |
| useFindAncestors | Find all ancestor entities in a tree structure |
| useFindByCursor | Find entities using cursor-based pagination |
| useFindDescendants | Find all descendant entities in a tree structure |
| useFindOne | Find one entity matching the criteria |
| useFindOneOrFail | Find one entity or throw an error if not found |
| useGet | 通过 ID 获取单个实体 |
| useGraphNeighbors | Find neighbor entities in a graph structure |
| useGraphPaths | Find paths between two entities in a graph |
| useInfiniteScroll | Infinite scroll hook for cursor-based pagination |