# parse-server-hooks

> React hooks for parse server

Latest version **0.1.4** (published 2022-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install parse-server-hooks
pnpm add parse-server-hooks
yarn add parse-server-hooks
bun add parse-server-hooks
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2022-08-11 |
| First published | 2022-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Simon |
| Maintainers | simonboisset |
| Keywords | parse-server, react, hooks |

## Links

- npm: https://www.npmjs.com/package/parse-server-hooks
- Repository: https://github.com/simonboisset/parse-server-hooks
- Issues: https://github.com/simonboisset/parse-server-hooks/issues
- npm.io page: https://npm.io/package/parse-server-hooks

## Dependencies (1)

- [@onehook/list](https://npm.io/package/@onehook/list.md) ^0.1.4

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2022-08-11
- 0.1.3 — 2022-08-10
- 0.1.2 — 2022-08-10
- 0.1.1 — 2022-08-09

## README

# Parse server hooks

React hooks for [parse-server](https://parseplatform.org/)

## Installation

```bash
yarn add parse-server-hooks
```

## Initialization

You need to define Parse as a global variable and initialize it before using hooks.

```ts
// React
import Parse from 'parse';
// React native
import Parse from 'parse/react-native.js';
Parse.setAsyncStorage(AsyncStorage);

global.Parse = Parse;

Parse.serverURL = serverURL;
Parse.initialize(applicationId, javascriptKey);
```

## Hooks

### useParseQuery

This hook return data of a `ParseQuery` and can enable `liveQuery` and rerender on each event.

```ts
const query = new Parse.Query(MyClass);

// In react component
const [data, { loading }] = useParseQuery({
  query,
  // Optionnal
  enableLiveQuery: true,
  onOpen,
  onUpdate,
  onDelete,
});

// Optionnal :
const mapData = (element: MyClass): MyFrontData => ({
  id: element.id,
  name: element.name,
});

const onOpen = ({ initialize }) => {
  const data = await query.findAll();
  initialize(data.map(mapData));
};

const onUpdate = (element: MyClass, { set }) => {
  set(mapData(element));
};

const onDelete = (element: MyClass, { remove }) => {
  remove(element.id);
};
```

You can use `onOpen`, `onUpdate` and `onDelete` to customize your data mapping on each events.

---
_Source: https://npm.io/package/parse-server-hooks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
