docs: Using Hooks#1056
Conversation
|
|
||
| ## Built-in Hooks | ||
|
|
||
| `Deephaven.ui` has a large number of built-in hooks to help with the development of components. The full documenation for these can be found in the `Hooks` section of the documentation. |
There was a problem hiding this comment.
There is no md file for hooks. It is in sidebar.json. Is there a way to link to this? I want to link users the section of the docs where they can access all the use_hook.md files.
There was a problem hiding this comment.
There is an overview file for hooks actually that would be appropriate. ../hooks/overview.md.
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
| - Custom hooks may call other hooks | ||
| - Custom hooks follow the same rules as built-in hooks. |
There was a problem hiding this comment.
Not sure how to word this better but it's worded kind of oddly right now.
Hooks can call other hooks, but usage of hooks within hooks follows the same rules as using hooks within components.
Co-authored-by: Mike Bender <mikebender@deephaven.io>
|
|
||
| See the [`use_state`](../hooks/use_state.md) documentation for more detailed information. | ||
|
|
||
| ### Use Memo Hook |
There was a problem hiding this comment.
Worth including details that table operations should typically be memoized with use_memo?
There was a problem hiding this comment.
I am going to put that in docs for "working with tables".
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
| @@ -0,0 +1,194 @@ | |||
| # Using Hooks | |||
There was a problem hiding this comment.
Avoid words ending with ing in titles.
|
|
||
| The `use_state` hook takes an optional parameter that is the initial state. It initializes to `None` if this is omitted. The hook returns two values: a state variable and a `set` function that lets you update the state and trigger a re-render. | ||
|
|
||
| See the [`use_state`](../hooks/use_state.md) documentation for more detailed information. |
There was a problem hiding this comment.
Instead of saying See the use_whatever documentation for more detailed info, why not just link to that documentation everywhere you mention use_whatever?
|
|
||
| ### Use Effect Hook | ||
|
|
||
| Call `use_effect` to synchronize a component with an external system. An effect runs when it is mounted or a dependency changes. An optional cleanup function runs when dependencies change or the component is unmounted. |
There was a problem hiding this comment.
Link to use_effect here.
|
|
||
| The `use_effect` hook takes two parameters: a callable and a list of dependencies. The callable may return a function for cleanup. | ||
|
|
||
| See the [`use_effect`](../hooks/use_effect.md) documentation for more detailed information. |
There was a problem hiding this comment.
This isn't necessary in every section if you just link to the guide wherever you mention use_effect, use_memo, etc.
|
|
||
|
|
||
| my_server = ui_server() | ||
| ``` |
There was a problem hiding this comment.
There is no related documentation for this section.
|
|
||
| The `use_callback` hook takes two parameters: a callable and a list of dependencies. It returns a memoized callback. The memoized callback is returned on subsequent renders until the dependencies change. | ||
|
|
||
| ## Rules for Hooks |
There was a problem hiding this comment.
should rules come before the types of hooks?
Rules
Built-in
Build your own
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
margaretkennedy
left a comment
There was a problem hiding this comment.
Two minor grammar updates
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
1941f88
https://deephaven.atlassian.net/browse/DOC-205