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

https://github.com/beizhedenglong/reason-hooks-lib

A set of reusable ReasonReact hooks.
https://github.com/beizhedenglong/reason-hooks-lib

hooks react-hooks reason-react

Last synced: 6 months ago
JSON representation

A set of reusable ReasonReact hooks.

Awesome Lists containing this project

README

          

# reason-hooks-lib

ReasonML implementation of [`react-hooks-lib`](https://github.com/beizhedenglong/react-hooks-lib).

```reason
open ReasonHooksLib;

[@react.component]
let make = () => {
open State;
let {past, present, future, set, undo, redo} = useUndo(0);


{"counter: " |> React.string}
{present |> string_of_int |> React.string}
set(prev => prev + 1)}>
{React.string("+1")}

undo()}>
{React.string("undo")}

redo()}>
{React.string("redo")}

;
};

```

## Installation
1. `yarn add reason-hooks-lib`
2. add `reason-hooks-lib` to `bs-dependencies` in your `bsconfig.json`

## Available Hooks
- **State**
- `useUndo`
- `useCounter`
- `useToggle`
- `useStateCallback`
- `createStore`
- **Lifecycle**
- `useDidMount`
- `useWillUnmount`
- `useDidUpdate`
- **Feedback**
- `useHover`

## Testing
If want to test your ReasonReact hooks easily, please take a look at [`reason-hooks-testing-library`](https://github.com/beizhedenglong/reason-hooks-testing-library).