Skip to content
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

Merged
merged 18 commits into from
Dec 16, 2024
Merged

docs: Using Hooks #1056

merged 18 commits into from
Dec 16, 2024

Conversation

dgodinez-dh
Copy link
Contributor

@dgodinez-dh dgodinez-dh commented Dec 5, 2024

plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved

## 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link?

Copy link
Contributor Author

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.

Copy link
Member

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.

plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
Comment on lines 150 to 151
- Custom hooks may call other hooks
- Custom hooks follow the same rules as built-in hooks.
Copy link
Member

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.


See the [`use_state`](../hooks/use_state.md) documentation for more detailed information.

### Use Memo Hook
Copy link
Contributor

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?

Copy link
Contributor Author

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".

plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/using_hooks.md Outdated Show resolved Hide resolved
mofojed
mofojed previously approved these changes Dec 6, 2024
margaretkennedy
margaretkennedy previously approved these changes Dec 9, 2024
@@ -0,0 +1,194 @@
# Using Hooks
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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()
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related documentation?

Copy link
Contributor Author

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.

Copy link
Contributor

@jjbrosnan jjbrosnan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments.

plugins/ui/docs/describing/use_hooks.md Outdated Show resolved Hide resolved

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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

plugins/ui/docs/describing/use_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/use_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/use_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/use_hooks.md Show resolved Hide resolved
plugins/ui/docs/describing/use_hooks.md Outdated Show resolved Hide resolved
Copy link
Contributor

@margaretkennedy margaretkennedy left a 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

plugins/ui/docs/describing/use_hooks.md Outdated Show resolved Hide resolved
plugins/ui/docs/describing/use_hooks.md Outdated Show resolved Hide resolved
jjbrosnan
jjbrosnan previously approved these changes Dec 16, 2024
@dgodinez-dh dgodinez-dh merged commit 28b5a51 into deephaven:main Dec 16, 2024
17 checks passed
@dgodinez-dh dgodinez-dh deleted the dag_Hooks branch December 17, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants