|
1 | 1 | # react-basic-hooks [](https://circleci.com/gh/spicydonuts/purescript-react-basic-hooks)
|
2 | 2 |
|
3 |
| -This is an experimental implementation of React hooks on [react-basic](https://github.com/lumihq/purescript-react-basic). |
| 3 | +This is library adds React hooks to [react-basic](https://github.com/lumihq/purescript-react-basic). |
4 | 4 |
|
5 |
| -*Warning:* This API relies on recent React versions (>= 16.8.0). |
| 5 | +_Warning:_ This API relies on recent React versions (>= 16.8.0). |
6 | 6 | For more info on hooks, see [React's documentation](https://reactjs.org/docs/hooks-intro.html).
|
7 | 7 |
|
8 | 8 | I recommend using PureScript's new "qualified do" syntax while using this library (it's used in the examples, the `React.do` bits).
|
9 |
| -It became available in the `0.12.2` compiler release. |
| 9 | +It became available in the `0.12.2` compiler release. |
10 | 10 |
|
11 | 11 | This library provides the `React.Basic.Hooks` module, which can completely replace the `React.Basic` module.
|
12 | 12 | It borrows a few types from the current `React.Basic` module like `ReactComponent` and `JSX` to make it easy to use both versions in the same project.
|
@@ -34,7 +34,9 @@ More examples:
|
34 | 34 | - Components: [Parent](./examples/component/src/Container.purs) and [Child](./examples/component/src/ToggleButton.purs)
|
35 | 35 | - [Refs to DOM nodes](./examples/refs/src/Refs.purs) (and extracting hook logic from a component for reuse)
|
36 | 36 | - [A Todo App](./examples/todo-app/src/TodoApp.purs) (components, inputs, state)
|
| 37 | +- [Context](./examples/context/src/Context.purs) (creating and consuming React context) |
| 38 | +- [Aff helper](./examples/aff/src/AffEx.purs) (async state management) |
37 | 39 |
|
38 |
| -*A note on Refs:* The `Ref` type is useful for all kinds of state (anything which shouldn't trigger a render when changed), particularly references to DOM nodes as in the example. |
| 40 | +_A note on Refs:_ The `Ref` type is useful for all kinds of state (anything which shouldn't trigger a render when changed), particularly references to DOM nodes as in the example. |
39 | 41 | Unfortunately, while this module remains a small extension to the existing react-basic library it won't be possible to pass a `ref` prop to the native DOM components from `React.Basic.DOM`.
|
40 | 42 | In the meantime, use `element (unsafeCreateDOMComponent "div") { ref: elementRef }`.
|
0 commit comments