mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
* Read through the docs and correct spelling and grammar * Run prettier * Apply review suggestions Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com> * adjust translation messages Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
21 lines
704 B
Plaintext
21 lines
704 B
Plaintext
---
|
|
title: 'Node Refs'
|
|
description: 'Out-of-band DOM access'
|
|
---
|
|
|
|
The `ref` attribute can be used to attach the `NodeRef` to an HTML element. In callbacks,
|
|
you can then get the DOM `Element` that the ref is attached to. This can be used to make
|
|
changes to the DOM outside of the `view` lifecycle method, retrieve the value of an `<input>`
|
|
and other direct interactions with the DOM via the javascript API.
|
|
|
|
This is useful for getting ahold of canvas elements, or scrolling to different sections of a page.
|
|
|
|
:::caution
|
|
Do not manually modify the DOM tree that is rendered by Yew. Treat the `NodeRef` as a read-only
|
|
access, if you are unsure.
|
|
:::
|
|
|
|
## Example
|
|
|
|
See [use_node_ref hook](./hooks/use-node-ref)
|