Skip to content

docs: Using Hooks#1056

Merged
dgodinez-dh merged 18 commits into
deephaven:mainfrom
dgodinez-dh:dag_Hooks
Dec 16, 2024
Merged

docs: Using Hooks#1056
dgodinez-dh merged 18 commits into
deephaven:mainfrom
dgodinez-dh:dag_Hooks

Conversation

@dgodinez-dh
Copy link
Copy Markdown
Contributor

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

Comment thread plugins/ui/docs/describing/using_hooks.md Outdated

## 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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

link?

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

Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment on lines +150 to +151
- Custom hooks may call other hooks
- Custom hooks follow the same rules as built-in hooks.
Copy link
Copy Markdown
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.

dgodinez-dh and others added 2 commits December 6, 2024 06:18
Co-authored-by: Mike Bender <mikebender@deephaven.io>

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

### Use Memo Hook
Copy link
Copy Markdown
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
Copy Markdown
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".

Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
mofojed
mofojed previously approved these changes Dec 6, 2024
Comment thread plugins/ui/docs/describing/using_hooks.md Outdated
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
margaretkennedy
margaretkennedy previously approved these changes Dec 9, 2024
@@ -0,0 +1,194 @@
# Using Hooks
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread plugins/ui/docs/describing/use_hooks.md Outdated
Comment thread plugins/ui/docs/describing/use_hooks.md Outdated

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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment thread plugins/ui/docs/describing/use_hooks.md Outdated
Comment thread plugins/ui/docs/describing/use_hooks.md Outdated
Comment thread plugins/ui/docs/describing/use_hooks.md Outdated
Comment thread plugins/ui/docs/describing/use_hooks.md
Comment thread plugins/ui/docs/describing/use_hooks.md Outdated
dgodinez-dh and others added 2 commits December 11, 2024 12:24
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
Copy link
Copy Markdown
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

Comment thread plugins/ui/docs/describing/use_hooks.md Outdated
Comment thread plugins/ui/docs/describing/use_hooks.md Outdated
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
jjbrosnan
jjbrosnan previously approved these changes Dec 16, 2024
@dgodinez-dh dgodinez-dh merged commit 28b5a51 into deephaven:main Dec 16, 2024
@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