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.
- Host: GitHub
- URL: https://github.com/beizhedenglong/reason-hooks-lib
- Owner: beizhedenglong
- Created: 2019-05-25T13:30:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-30T16:03:31.000Z (over 5 years ago)
- Last Synced: 2025-06-15T13:05:58.902Z (7 months ago)
- Topics: hooks, react-hooks, reason-react
- Language: Reason
- Homepage:
- Size: 440 KB
- Stars: 31
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
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).