Skip to content

Commit 13b2718

Browse files
committed
コード内のコメントの残りも翻訳
1 parent 020b62b commit 13b2718

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

content/docs/portals.md

+10-13
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,11 @@ class Modal extends React.Component {
8181
}
8282
8383
componentDidMount() {
84-
// The portal element is inserted in the DOM tree after
85-
// the Modal's children are mounted, meaning that children
86-
// will be mounted on a detached DOM node. If a child
87-
// component requires to be attached to the DOM tree
88-
// immediately when mounted, for example to measure a
89-
// DOM node, or uses 'autoFocus' in a descendant, add
90-
// state to Modal and only render the children when Modal
91-
// is inserted in the DOM tree.
84+
// ポータルの要素が DOM ツリーに挿入されるのは、 Modal の子要素がマウントされた後になります。
85+
// つまり、子要素は一旦どこにも結びつかない DOM ノードへとマウントされるということです。
86+
// もし子コンポーネントがマウント後すぐに DOM ツリーに結びついてほしい ――
87+
// たとえば DOM ノードの大きさを測りたい、子孫要素で `autoFocus` を使いたいなど
88+
// ―― 場合は、 Modal に状態を持たせて子要素が DOM ツリーに入ったときだけ描画されるようにしましょう。
9289
modalRoot.appendChild(this.el);
9390
}
9491
@@ -112,9 +109,9 @@ class Parent extends React.Component {
112109
}
113110
114111
handleClick() {
115-
// This will fire when the button in Child is clicked,
116-
// updating Parent's state, even though button
117-
// is not direct descendant in the DOM.
112+
// これは Child 内のボタンがクリックされた時に発行され、
113+
// Parentstate を更新します。
114+
// たとえそのボタンが DOM 上では直系の子孫でなかったとしてもです。
118115
this.setState(state => ({
119116
clicks: state.clicks + 1
120117
}));
@@ -139,8 +136,8 @@ class Parent extends React.Component {
139136
}
140137
141138
function Child() {
142-
// The click event on this button will bubble up to parent,
143-
// because there is no 'onClick' attribute defined
139+
// クリックするとイベントが親に伝播します。
140+
// なぜならここには `onClick` 属性が定義されてないからです。
144141
return (
145142
<div className="modal">
146143
<button>Click</button>

0 commit comments

Comments
 (0)