Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dom-bundle
- Loading branch information
Showing
5 changed files
with
60 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...cusaurus-plugin-content-docs/current/advanced-topics/struct-components/refs.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
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(); | ||
``` | ||
|
c1a7ba9
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.
Yew master branch benchmarks (Lower is better)
yew-struct-keyed 01_run1k
161.952
210.1425
0.77
yew-struct-keyed 02_replace1k
180.2415
226.9655
0.79
yew-struct-keyed 03_update10th1k_x16
418.801
393.74
1.06
yew-struct-keyed 04_select1k
77.785
89.3675
0.87
yew-struct-keyed 05_swap1k
90.681
102.049
0.89
yew-struct-keyed 06_remove-one-1k
27.7025
34.9915
0.79
yew-struct-keyed 07_create10k
1893.6195
2382.73
0.79
yew-struct-keyed 08_create1k-after1k_x2
384.038
467.164
0.82
yew-struct-keyed 09_clear1k_x8
200.3
186.206
1.08
yew-struct-keyed 21_ready-memory
0.9634475708007812
0.9634475708007812
1
yew-struct-keyed 22_run-memory
1.5048332214355469
1.5028305053710938
1.00
yew-struct-keyed 23_update5-memory
1.5063819885253906
1.4616203308105469
1.03
yew-struct-keyed 24_run5-memory
1.5059242248535156
1.5110435485839844
1.00
yew-struct-keyed 25_run-clear-memory
1.128643035888672
1.1257438659667969
1.00
yew-struct-keyed 31_startup-ci
1810.3185000000003
1789.48175
1.01
yew-struct-keyed 32_startup-bt
34.26399999999999
37.82199999999999
0.91
yew-struct-keyed 34_startup-totalbytes
359.8974609375
359.8974609375
1
This comment was automatically generated by workflow using github-action-benchmark.