Muhammad Hamza f0209c786f
Prepare for Yew 0.20 (#2973)
* 0.20 Changelog

* Improve changelog generator

* Add blog post

* Add blog post

* Apply suggestions from code review

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>
Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

* update Changelog

* update Cargo.toml

* changelog gen compiles

* website version 0.20

* add migration guides

* prettier

* i18n

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>
Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2022-11-25 15:19:07 +05:00

25 lines
746 B
Plaintext

---
title: Refs
description: Out-of-band DOM access
---
`ref`は、任意の HTML 要素やコンポーネントの内部で、割り当てられている DOM`Element`を取得するために使用することができます。
これは、`view` ライフサイクルメソッドの外で DOM に変更を加えるために使用できます。
これは、キャンバスの要素を取得したり、ページの異なるセクションにスクロールしたりするのに便利です。
構文は以下の通りです:
```rust
// In create
self.node_ref = NodeRef::default();
// In view
html! {
<div ref={self.node_ref.clone()}></div>
}
// In update
let has_attributes = self.node_ref.try_into::<Element>().has_attributes();
```