# @opendevtools/rescript-hooks

> A collection of reusable hooks for ReasonML

Latest version **0.1.5** (published 2020-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @opendevtools/rescript-hooks
pnpm add @opendevtools/rescript-hooks
yarn add @opendevtools/rescript-hooks
bun add @opendevtools/rescript-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.5 |
| Published | 2020-11-18 |
| First published | 2020-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | believer |
| Maintainers | believer, dubbelnisse |
| Keywords | Hooks, ReasonML |

## Links

- npm: https://www.npmjs.com/package/@opendevtools/rescript-hooks
- Repository: https://github.com/opendevtools/rescript-hooks
- Homepage: https://github.com/opendevtools/rescript-hooks#readme
- Issues: https://github.com/opendevtools/rescript-hooks/issues
- npm.io page: https://npm.io/package/@opendevtools/rescript-hooks

## Dependencies (1)

- [query-string](https://npm.io/package/query-string.md) ^6.13.7

## Recent versions

- 0.1.5 (latest) — 2020-11-18

## README

# Hooks for ReasonML

This is a port of [@opendevtools/hooks](https://github.com/opendevtools/hooks) for ReasonML/BuckleScript. Still a work in progress.

## Installation

```bash
npm install @opendevtools/rescript-hooks
```

Add `@opendevtools/rescript-hooks` to `bs-dependencies` in `bsconfig.json`

## Available Hooks

- [useToggle](#useToggle)
- [useQueryParam](#useQueryParam)

### [useToggle](#useToggle)

```reason
useToggle(~initialState: option(bool), unit): (bool, unit => unit)
```

`initialState` is set to `false` by default, that's why it's an `option(bool)`

#### Example

```reason
[@react.component]
let make = () => {
  let (isAlive, toggleValue) = OpenDevToolsHooks.useToggle();

  <button onClick={_ => toggleValue()}>
    {
      isAlive ? {j|🚀|j} : {j|😴|j};
    }
    ->React.string
  </button>;
};
```

### [useQueryParam](#useQueryParam)

Gets a value from a specified query param

```reason
useQueryParam(~param: Js.Dict.key): string
```

#### Example

```reason
[@react.component]
let make = () => {
  let param = OpenDevToolsHooks.useQueryParam(~param="sweetParam");

  <div>
    {"That's a nice query param with the value " ++ param |> React.string}
  </div>;
};

```

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