-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Using Hooks #1056
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an overview file for hooks actually that would be appropriate. ../hooks/overview.md
.
Co-authored-by: margaretkennedy <[email protected]>
- Custom hooks may call other hooks | ||
- Custom hooks follow the same rules as built-in hooks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
|
||
See the [`use_state`](../hooks/use_state.md) documentation for more detailed information. | ||
|
||
### Use Memo Hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth including details that table operations should typically be memoized with use_memo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to put that in docs for "working with tables".
Co-authored-by: margaretkennedy <[email protected]>
@@ -0,0 +1,194 @@ | |||
# Using Hooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid words ending with ing
in titles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of saying See the use_whatever documentation for more detailed info
, why not just link to that documentation everywhere you mention use_whatever
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
### 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to use_effect
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary in every section if you just link to the guide wherever you mention use_effect
, use_memo
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
|
||
my_server = ui_server() | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no related documentation for this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments.
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should rules come before the types of hooks?
Rules
Built-in
Build your own
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Co-authored-by: margaretkennedy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor grammar updates
Co-authored-by: margaretkennedy <[email protected]>
1941f88
https://deephaven.atlassian.net/browse/DOC-205