# @tuya-miniapp/redux-connect-page

> 小程序中用于替代 Page 方法，直接关联 redux 状态，类似于 redux 中 connect 方法

Latest version **0.0.5** (published 2023-05-20) · 0 weekly downloads

## Install

```sh
npm install @tuya-miniapp/redux-connect-page
pnpm add @tuya-miniapp/redux-connect-page
yarn add @tuya-miniapp/redux-connect-page
bun add @tuya-miniapp/redux-connect-page
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2023-05-20 |
| First published | 2022-12-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | tuyafe |

## Links

- npm: https://www.npmjs.com/package/@tuya-miniapp/redux-connect-page
- npm.io page: https://npm.io/package/@tuya-miniapp/redux-connect-page

## Recent versions

- 0.0.5 (latest) — 2023-05-20
- 0.0.4 — 2023-05-18
- 0.0.3 — 2022-12-19

## README

# miniapp-redux-connect-page

小程序中用于替代 Page 方法，直接关联 redux 状态，类似于 redux 中 connect 方法

## 安装

```shell
yarn add @tuya-miniapp/redux-connect-page
```

## 使用

### 单 store 配置

```javascript
// app.js
import { setGlobalStore } from '@tuya-miniapp/redux-connect-page';
import { store } from 'path/to/store';
setGlobalStore(store);

App({
    ...
})
```

### 多 store 配置

```javascript
// page.js
import { store } from 'path/to/store';
ty.ConnectPage({
    onLoad: function() {

    },
    ...
}, [/*mapStateToData*/], () => {/*mapDispatchToProps*/}, store)
```

### 重载 Page

若所有 Page 下都使用到了 redux，可通过重载 Page 方法的形式处理每个页面，这样就不再需要每个页面都导入 ConnectPage 了。

```javascript
import { setGlobalStore } from '@tuya-miniapp/redux-connect-page';
import { store } from 'path/to/store';

Page = ty.ConnectPage;
setGlobalStore(store);

Page({
    onLoad: function() {

    },
    ...
}, [/*mapStateToData*/], () => {/*mapDispatchToProps*/})

```

---
_Source: https://npm.io/package/@tuya-miniapp/redux-connect-page · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
