-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(hooks): add usage example for hooks (#991)
The type signatures for the hooks are quite hard to read. Especially since most parts of it are abstracted away by the brisk-reconciler. This change makes it easier to discover how to use the common hooks. ![image](https://user-images.githubusercontent.com/18226001/90973151-9b1ac500-e562-11ea-8770-5a88dacc5f33.png)
- Loading branch information
1 parent
f63a135
commit 836351d
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
open Revery_UI.React.Hooks; | ||
|
||
/** | ||
{2 Description:} | ||
An alternative to Hooks.state. Accepts a reducer of type (action, state) => newState, and returns the current state paired with a dispatch function. | ||
{2 Usage:} | ||
{[ | ||
let%hook (state, dispatch) = Hooks.reducer(~initialState={counter:0}, reduce); | ||
]} | ||
*/ | ||
let reducer: | ||
(~initialState: 'a, ('b, 'a) => 'a, t(Reducer.t('a) => 'c, 'd)) => | ||
(('a, 'b => unit), t('c, 'd)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
open Revery_UI.React.Hooks; | ||
|
||
/** | ||
{2 Description:} | ||
TODO | ||
{2 Usage:} | ||
{[ | ||
let%hook (state, setState) = Hooks.state(0); | ||
]} | ||
*/ | ||
let state: | ||
('a, t(State.t('a) => 'b, 'c)) => (('a, ('a => 'a) => unit), t('b, 'c)); |