Skip to content

Commit 1f1cd2e

Browse files
authored
Merge pull request #142 from jay-es/functional-components
Migration Guide > Functional Components の翻訳
2 parents 69d5c62 + fc80c14 commit 1f1cd2e

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/guide/migration/functional-components.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@ badges:
33
- breaking
44
---
55

6-
# Functional Components <MigrationBadges :badges="$frontmatter.badges" />
6+
# 関数型コンポーネント <MigrationBadges :badges="$frontmatter.badges" />
77

8-
## Overview
8+
## 概要
99

10-
In terms of what has changed, at a high level:
10+
何が変わったのかを大まかに:
1111

12-
- Performance gains from 2.x for functional components are now negligible in 3.x, so we recommend just using stateful components
13-
- Functional components can only be created using a plain function that receives `props` and `context` (i.e., `slots`, `attrs`, `emit`)
14-
- **BREAKING:** `functional` attribute on single-file component (SFC) `<template>` is removed
15-
- **BREAKING:** `{ functional: true }` option in components created by functions is removed
12+
- 関数型コンポーネントの 2.x からのパフォーマンスの向上は 3.x ではごくわずかなので、ステートフルコンポーネントのみの使用を推奨します
13+
- 関数型コンポーネントは、`props` `context`(つまり `slots`, `attrs`, `emit`)を受け取るプレーンな関数を用いてのみ作成できます
14+
- **破壊的変更:** 単一ファイルコンポーネント(SFC)の `<template>` から `functional` 属性は削除されました
15+
- **破壊的変更:** 関数で作られるコンポーネントの `{ function: true }` オプションは削除されました
1616

17-
For more information, read on!
17+
詳細については、続きを読んでください!
1818

19-
## Introduction
19+
## はじめに
2020

21-
In Vue 2, functional components had two primary use cases:
21+
Vue 2 では、関数型コンポーネントには 2 つの主要なユースケースがありました:
2222

23-
- as a performance optimization, because they initialized much faster than stateful components
24-
- to return multiple root nodes
23+
- ステートフルコンポーネントよりもはるかに高速に初期化されるので、パフォーマンスの最適化として
24+
- 複数のルートノードを返すため
2525

26-
However, in Vue 3, the performance of stateful components has improved to the point that the difference is negligible. In addition, stateful components now also include the ability to return multiple root nodes.
26+
しかし Vue 3 では、ステートフルコンポーネントのパフォーマンスは、その差が無視できるほどに向上しています。さらに、ステートフルコンポーネントに複数のルートノードを返す機能も追加されました。
2727

28-
As a result, the only remaining use case for functional components is simple components, such as a component to create a dynamic heading. Otherwise, it is recommended to use stateful components as you normally would.
28+
その結果、関数型コンポーネントに残った唯一のユースケースは、動的な見出しを作成するためのコンポーネントのようなシンプルなものだけです。それ以外の場合は、通常どおりステートフルコンポーネントを使用することをお勧めします。
2929

30-
## 2.x Syntax
30+
## 2.x のシンタックス
3131

32-
Using the `<dynamic-heading>` component, which is responsible for rendering out the appropriate heading (i.e., `h1`, `h2`, `h3`, etc.), this could have been written as a single-file component in 2.x as:
32+
`<dynamic-heading>` コンポーネントを使うと、適切な見出し(つまり `h1`, `h2`, `h3` など)のレンダリングを担当するコンポーネントは 2.x では単一ファイルコンポーネントとして次のように記述できました:
3333

3434
```js
35-
// Vue 2 Functional Component Example
35+
// Vue 2 での関数型コンポーネントの例
3636
export default {
3737
functional: true,
3838
props: ['level'],
@@ -42,10 +42,10 @@ export default {
4242
}
4343
```
4444

45-
Or, for those who preferred the `<template>` in a single-file component:
45+
または、単一ファイルコンポーネントの `<template>` を好む人向けに:
4646

4747
```js
48-
// Vue 2 Functional Component Example with <template>
48+
// Vue 2 での <template> を使用した関数型コンポーネントの例
4949
<template functional>
5050
<component
5151
:is="`h${props.level}`"
@@ -61,17 +61,17 @@ export default {
6161
</script>
6262
```
6363

64-
## 3.x Syntax
64+
## 3.x のシンタックス
6565

66-
### Components Created by Functions
66+
### 関数で作られるコンポーネント
6767

68-
Now in Vue 3, all functional components are created with a plain function. In other words, there is no need to define the `{ functional: true }` component option.
68+
Vue 3 では、すべての関数型コンポーネントはプレーンな関数で作成されます。つまり、`{ function: true }` のコンポーネントオプションを定義する必要はありません。
6969

70-
They will receive two arguments: `props` and `context`. The `context` argument is an object that contains a component's `attrs`, `slots`, and `emit` properties.
70+
これらの関数は `props`` context` の 2 つの引数を受け取ります。`context` 引数は、コンポーネントの `attrs`, `slot`, `emit` プロパティを含むオブジェクトです。
7171

72-
In addition, rather than implicitly provide `h` in a `render` function, `h` is now imported globally.
72+
さらに、`render` 関数内で暗黙的に `h` を提供するのではなく、`h` をグローバルにインポートするようになりました。
7373

74-
Using the previously mentioned example of a `<dynamic-heading>` component, here is how it looks now.
74+
前述の `<dynamic-heading>` コンポーネントの例を使って、どのようになったかを説明します。
7575

7676
```js
7777
import { h } from 'vue'
@@ -85,11 +85,11 @@ DynamicHeading.props = ['level']
8585
export default DynamicHeading
8686
```
8787

88-
### Single File Components (SFCs)
88+
### 単一ファイルコンポーネント (SFC)
8989

90-
In 3.x, the performance difference between stateful and functional components has been drastically reduced and will be insignificant in most use cases. As a result, the migration path for developers using `functional` on SFCs is to remove the attribute. No additional work required.
90+
3.x では、ステートフルコンポーネントと関数型コンポーネントのパフォーマンスの差は大幅に減少し、ほとんどのユースケースでは重要ではないでしょう。その結果、単一ファイルコンポーネントで `functional` を使用している開発者の移行方法は、その属性を削除することです。 追加の作業は必要ありません。
9191

92-
Using our `<dynamic-heading>` example from before, here is how it would look now.
92+
先ほどの `<dynamic-heading>` の例を使うと、次のようになります。
9393

9494
```js{1}
9595
<template>
@@ -106,14 +106,14 @@ export default {
106106
</script>
107107
```
108108

109-
The main differences are that:
109+
主な違いは以下の通りです:
110110

111-
1. `functional` attribute removed on `<template>`
112-
1. `listeners` are now passed as part of `$attrs` and can be removed
111+
1. `<template>` から `functional` 属性が削除されました
112+
1. `listeners` `$attrs` の一部として渡されるようになるので、削除できるようになりました
113113

114-
## Next Steps
114+
## 次のステップ
115115

116-
For more information on the usage of the new functional components and the changes to render functions in general, see:
116+
新しい関数型コンポーネントの使用方法や render 関数全般の変更点の詳細は、以下を参照してください:
117117

118-
- [Migration: Render Functions](/guide/migration/render-function-api.html)
119-
- [Guide: Render Functions](/guide/render-function.html)
118+
- [移行: Render 関数](/guide/migration/render-function-api.html)
119+
- [ガイド: Render 関数](/guide/render-function.html)

0 commit comments

Comments
 (0)