You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/reference/react/createRef.md
+23-23
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ title: createRef
4
4
5
5
<Pitfall>
6
6
7
-
`createRef`is mostly used for [class components.](/reference/react/Component) Function components typically rely on [`useRef`](/reference/react/useRef)instead.
@@ -40,31 +40,31 @@ class MyComponent extends Component {
40
40
// ...
41
41
```
42
42
43
-
[See more examples below.](#usage)
43
+
[さらに例を見る](#usage)
44
44
45
-
#### Parameters {/*parameters*/}
45
+
#### 引数 {/*parameters*/}
46
46
47
-
`createRef`takes no parameters.
47
+
`createRef`は引数を取りません。
48
48
49
-
#### Returns {/*returns*/}
49
+
#### 返り値 {/*returns*/}
50
50
51
-
`createRef`returns an object with a single property:
51
+
`createRef`は単一のプロパティを持つオブジェクトを返します。
52
52
53
-
* `current`: Initially, it's set to the `null`. You can later set it to something else. If you pass the ref object to React as a `ref` attribute to a JSX node, React will set its `current`property.
If you now pass `ref={this.inputRef}`to an `<input>` in your JSX, React will populate `this.inputRef.current`with the input DOM node. For example, here is how you make a button that focuses the input:
@@ -107,17 +107,17 @@ export default class Form extends Component {
107
107
108
108
<Pitfall>
109
109
110
-
`createRef`is mostly used for [class components.](/reference/react/Component) Function components typically rely on [`useRef`](/reference/react/useRef) instead.
We recommend using function components instead of [class components](/reference/react/Component) in new code. If you have some existing class components using `createRef`, here is how you can convert them. This is the original code:
@@ -146,7 +146,7 @@ export default class Form extends Component {
146
146
147
147
</Sandpack>
148
148
149
-
When you [convert this component from a class to a function,](/reference/react/Component#alternatives) replace calls to `createRef`with calls to [`useRef`:](/reference/react/useRef)
0 commit comments