Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit e3faaf6

Browse files
author
BSKY
authored
Merge pull request #170 from blkclct/docs/adding-react-components
translated docs/adding react components
2 parents 72f6b06 + 2a4170e commit e3faaf6

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
2-
title: Adding React Components
2+
title: React コンポーネントを追加する
33
---
44

5-
This guide covers how to add React components, including those from third-party component libraries, to your Gatsby site.
5+
このガイドは、あなたの Gatsby サイトにサードパーティコンポーネントライブラリーも含む React コンポーネントの追加方法を解説します。
66

7-
## React components
7+
## React コンポーネント
88

9-
React components are prebuilt elements or groups of elements that can be used to split your user interface (UI) into independent, reusable pieces. There are multiple types of components you can write but this guide covers functional components. For more in-depth information on writing React components, including classes, check out the [React documentation](https://reactjs.org/docs/components-and-props.html).
9+
React コンポーネントは、ユーザーインターフェース(UI)を独立した再利用可能な部品として分割するために使えるすでに構築された要素、もしくは要素の集合です。React コンポーネントで書くことができるコンポーネントの種類は多くあるのですが、このガイドでは、関数コンポーネントを使用します。クラスコンポーネントを含む React コンポーネントの書き方について詳細を知りたい場合は、こちらの [React ドキュメント](https://ja.reactjs.org/docs/components-and-props.html)をご覧ください。
1010

11-
Components can also be customized using inputs, better known as "props" (properties). Props can be of any JavaScript data type, such as Boolean, String, or Object.
11+
コンポーネントは、"props"(プロパティ)として知られる入力を用いてカスタマイズされる機能も提供されています。 Props は、ブーリアンや文字列、オブジェクトのような JavaScript の型になりえます。
1212

13-
For example, you could use a component for Buttons on your site. This would enable them to be used multiple times across pages with different labels or actions each time.
13+
例えば、あなたのサイト上のボタンに対してコンポーネントを使えます。これで、毎回異なるラベルやアクションを持つページを越えて、複数回使用できます。
1414

15-
## Importing React components
15+
## React コンポーネントをインポートする
1616

17-
In Gatsby, when using React components, you can import and use them like you would in a React application. Here's an example of the [Gatsby Link](/docs/gatsby-link/) component in action, which brings with it extra functionality for performance:
17+
GatsbyReact コンポーネントを使うときは、React アプリケーションと同じようにしてインポートして使用できます。ここでは、動作している [Gatsby Link](/docs/gatsby-link/) を例にします。そして、パフォーマンスのための追加機能をもたらします。
1818

1919
```jsx
2020
import React from "react"
@@ -27,68 +27,68 @@ export default () => (
2727
)
2828
```
2929

30-
### Importing third-party components
30+
### サードパーティコンポーネントをインポートする
3131

32-
Just like React, Gatsby also supports third-party components and libraries. You can install a third-party component or library via your package manager. We tend to favor and use npm and we will reflect this in our examples.
32+
React と同様にして、Gatsby でもサードパーティコンポーネントとライブラリはサポートしています。あなたは、パッケージマネジャ経由でサードパーティコンポーネントやライブラリをインストールできます。私たちは、npm を好んで使用する傾向にあるので、npm を例にしています。
3333

34-
Here's an example of adding a third-party component to your site.
34+
ここでは、サイトにサードパーティコンポーネントを追加する一例を挙げています。
3535

36-
First, you have to install the component or library's package via a package manager. It's recommended not to mix package managers, so if you use npm, don't use another and vice versa. If there's a relevant Gatsby plugin, you should install and use that plugin.
36+
はじめに、パッケージマネジャでコンポーネントやライブラリのパッケージをインストールしなければなりません。パッケージマネジャを組み合わせることはおすすめしません。なので、もしあなたが npm を使用するなら別のものは使用しないことをおすすめします。また逆もまた然りです。もし関連する Gatsby プラグインがある場合は、そのプラグインをインストールして使用する必要があります。
3737

38-
In this example, you'll install both a plugin and the library it depends on:
38+
この例では、プラグインとプラグインに依存するライブラリーの両方をインストールします。
3939

4040
```shell
4141
npm install gatsby-plugin-material-ui @material-ui/core
4242
```
4343

44-
After installation, add any necessary plugins to the plugins array in `gatsby-config.js`:
44+
パッケージのインストールが完了したら、`gatsby-config.js` のプラグイン配列に必要なプラグインを追加します。
4545

4646
```js:title=gatsby-config.js
4747
module.exports = {
4848
plugins: [`gatsby-plugin-material-ui`],
4949
}
5050
```
5151

52-
Import and use the library in your page's source:
52+
そして、あなたのページのソースコード上でインポートして使用します。
5353

5454
```jsx:title=index.js
5555
import React from "react"
5656

57-
// import my fancy third-party component
57+
// わたしの素敵なサードパーティコンポーネントをインポートする
5858
import Button from "@material-ui/core/Button"
5959

6060
export default () => (
6161
<div>
62-
<p>This is my super awesome page made with Gatsby!</p>
62+
<p>これは、わたしの超すごい Gatsby でできたページです!</p>
6363

64-
{/* use my fancy third-party component */}
65-
<Button variant="contained">Fancy button!</Button>
64+
{/* わたしの素敵なサードパーティコンポーネントを使用する */}
65+
<Button variant="contained">素敵なボタン!</Button>
6666
</div>
6767
)
6868
```
6969

70-
## Things to watch out for
70+
## 気をつけるべきこと
7171

72-
Since Gatsby uses server-side rendering (SSR) to generate your site's pages, the JSX code you write is usually compiled before the browser loads the page. Because of this, certain features are not available at compile time and can cause a build error.
72+
Gatsby は、サーバサイドレンダリング(SSR)を使用してサイトのページを生成しているため、たいていの場合、ブラウザがページをロードする前にあなたが書いた JSX のコードが、コンパイルされます。このため、ある機能は、コンパイルした時に利用できずビルドエラーとなることがあります。
7373

74-
### Use of browser globals
74+
### ブラウザグローバルの使用について
7575

76-
Some components or code reference browser globals such as `window`, `document` or `localStorage`. These objects are not available at [build](/docs/glossary#build) time and can result in a webpack error when compiling:
76+
一部のコンポーネントやコードでは、`window``document``localStorage` のようなブラウザグローバルを参照することがあります。それらのオブジェクトでは、[ビルド](/docs/glossary#build)時点では利用できず、コンパイル時に webpack エラーが発生することもあります。
7777

7878
```text
7979
WebpackError: ReferenceError: window is not defined
8080
```
8181

82-
To learn more about solutions for supporting SSR and client-side libraries, check out the related documentation section on [Porting from Create React App](/docs/porting-from-create-react-app-to-gatsby#server-side-rendering-and-browser-apis).
82+
SSR およびクライアントサイドライブラリをサポートする解決策については、[Create React App から Gatsby への移植](/docs/porting-from-create-react-app-to-gatsby#server-side-rendering-and-browser-apis)に関連するセクションをご覧ください。
8383

84-
#### Fixing third-party modules
84+
#### サードパーティモジュールを直す
8585

86-
Some packages expect `window` or another browser global to be defined. These packages will have to be patched.
86+
一部のパッケージは、`window` もしくは、別のブラウザグローバルが定義されることを期待します。それらのパッケージは、パッチを適用する必要があります。
8787

88-
You can learn how to patch these packages on the [Debugging HTML Builds documentation](/docs/debugging-html-builds/#fixing-third-party-modules).
88+
[HTML ビルドのデバッグ](/docs/debugging-html-builds/#fixing-third-party-modules)でそれらのパッケージにパッチを適用する方法を学べます。
8989

90-
### Components without server-side rendering
90+
### サーバサイドレンダリングなしのコンポーネント
9191

92-
Server-side rendering means pages and content are built out by the Node.js server and then sent to a browser ready to go. It’s like your pages are constructed before even being sent to the user. Gatsby is server-side rendered at build time, meaning that the code that gets to your browser has already been run to build pages and content, but this doesn’t mean you can’t still have dynamic pages.
92+
サーバサイドレンダリングは、ページとコンテンツが Node.js サーバーでビルドされ、ブラウザーに送信されることを意味します。ユーザーに送信される前で、ページが構築されるようなものです。Gatsby では、ビルド時にサーバサイドでレンダリングされます。つまり、ブラウザーに到達するコードは、すでにページとコンテンツをビルドするために実行されています。しかし、これはまだ動的なページを保持できないことを意味します。
9393

94-
Some React components don't have server-side rendering support (SSR) out-of-the-box so you might have to add SSR yourself.
94+
一部の React コンポーネントは、デフォルトでサーバサイドレンダリング(SSR)がサポートされていないため、SSR を自分自身で追加する必要があるかもしれません。

0 commit comments

Comments
 (0)