Skip to content

Commit 957eccf

Browse files
balazsorban44gergely-nagy
authored andcommitted
Components and Props translation (#9)
* 🌐 translate Components and Props
1 parent 70bb69a commit 957eccf

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

content/docs/components-and-props.md

+54-54
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: components-and-props
3-
title: Components and Props
3+
title: Komponensek és prop-ok
44
permalink: docs/components-and-props.html
55
redirect_from:
66
- "docs/reusable-components.html"
@@ -16,60 +16,60 @@ prev: rendering-elements.html
1616
next: state-and-lifecycle.html
1717
---
1818

19-
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to the idea of components. You can find a [detailed component API reference here](/docs/react-component.html).
19+
A komponensek lehetővé teszik számodra a felhasználói felület független, újrafelhasználható darabokra való felosztását, és segítenek hogy minden darabról a többitől elzártan tudj gondolkodni. Ez az oldal a komponensek lényegét mutatja be. A [részletes komponens API referenciát itt](/docs/react-component.html) találod.
2020

21-
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called "props") and return React elements describing what should appear on the screen.
21+
Elviekben a komponensek olyanok mint a JavaScript függvények. Egy tetszőleges számú inputot fogadnak (amiket "prop"-oknak hívunk) és egy React elemet adnak vissza ami leírja mi jelenjen meg a képernyőn.
2222

23-
## Function and Class Components {#function-and-class-components}
23+
## Függvény és Osztály komponensek {#function-and-class-components}
2424

25-
The simplest way to define a component is to write a JavaScript function:
25+
Egy komponens legegyszerűbb definiálásának módja egy JavaScript függvény:
2626

2727
```js
2828
function Welcome(props) {
29-
return <h1>Hello, {props.name}</h1>;
29+
return <h1>Helló, {props.name}</h1>;
3030
}
3131
```
3232

33-
This function is a valid React component because it accepts a single "props" (which stands for properties) object argument with data and returns a React element. We call such components "function components" because they are literally JavaScript functions.
33+
Ez a függvény egy érvényes React komponens, mivel egyetlen "props" (angol properties, vagy tulajdonságok) objektum argumentuma van ami adatot tartalmaz, és egy React elemet ad vissza. Egy ilyen komponenst hívunk "függvény komponensnek", mert szó szerint csak egy JavaScript függvény.
3434

35-
You can also use an [ES6 class](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) to define a component:
35+
Emellett használhatsz [ES6 osztályokat](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) is komponensek definiálásához:
3636

3737
```js
3838
class Welcome extends React.Component {
3939
render() {
40-
return <h1>Hello, {this.props.name}</h1>;
40+
return <h1>Helló, {this.props.name}</h1>;
4141
}
4242
}
4343
```
4444

45-
The above two components are equivalent from React's point of view.
45+
A React szemszögéből a fenti két komponens egymással megegyező.
4646

47-
Classes have some additional features that we will discuss in the [next sections](/docs/state-and-lifecycle.html). Until then, we will use function components for their conciseness.
47+
Az osztályok rendelkeznek pár extra funkcióval, amit a [következő fejezetekben](/docs/state-and-lifecycle.html) beszélünk ki. Addig is a függvény komponenseket használjuk tömörségük miatt.
4848

49-
## Rendering a Component {#rendering-a-component}
49+
## Egy komponens renderelése {#rendering-a-component}
5050

51-
Previously, we only encountered React elements that represent DOM tags:
51+
Korábban csak olyan React elemekkel találkoztunk, amik csak DOM címkéket képviseltek:
5252

5353
```js
5454
const element = <div />;
5555
```
5656

57-
However, elements can also represent user-defined components:
57+
Azonban az elemek képviselhetnek a felhasználó által definiált komponenseket is:
5858

5959
```js
60-
const element = <Welcome name="Sara" />;
60+
const element = <Welcome name="Sára" />;
6161
```
6262

63-
When React sees an element representing a user-defined component, it passes JSX attributes to this component as a single object. We call this object "props".
63+
Ha a React egy olyan elemet lát ami egy felhasználó által definiált komponenst képvisel, akkor leküldi a JSX attribútumokat a komponensnek egy sima objektumként. Ezt az objektumot hívjuk "props"-nak.
6464

65-
For example, this code renders "Hello, Sara" on the page:
65+
Például ez a kód a "Helló, Sára" szöveget rendereli az oldalon:
6666

6767
```js{1,5}
6868
function Welcome(props) {
69-
return <h1>Hello, {props.name}</h1>;
69+
return <h1>Helló, {props.name}</h1>;
7070
}
7171
72-
const element = <Welcome name="Sara" />;
72+
const element = <Welcome name="Sára" />;
7373
ReactDOM.render(
7474
element,
7575
document.getElementById('root')
@@ -78,36 +78,36 @@ ReactDOM.render(
7878

7979
[](codepen://components-and-props/rendering-a-component)
8080

81-
Let's recap what happens in this example:
81+
Foglaljuk össze mi történik ebben a példában:
8282

83-
1. We call `ReactDOM.render()` with the `<Welcome name="Sara" />` element.
84-
2. React calls the `Welcome` component with `{name: 'Sara'}` as the props.
85-
3. Our `Welcome` component returns a `<h1>Hello, Sara</h1>` element as the result.
86-
4. React DOM efficiently updates the DOM to match `<h1>Hello, Sara</h1>`.
83+
1. Meghívjuk a `ReactDOM.render()` metódust a `<Welcome name="Sára" />` elemmel.
84+
2. A React meghívja a `Welcome` komponenst a `{name: 'Sára'}` props objektummal.
85+
3. A `Welcome` komponensünk visszaadja a `<h1>Helló, Sára</h1>` elemet eredményként.
86+
4. A React DOM hatékonyan frissíti a DOM-ot hogy az megegyezzen a `<h1>Helló, Sára</h1>`-val.
8787

88-
>**Note:** Always start component names with a capital letter.
88+
>**Megjegyzés:** A komponensek neveit mindig nagybetűvel kezdd.
8989
>
90-
>React treats components starting with lowercase letters as DOM tags. For example, `<div />` represents an HTML div tag, but `<Welcome />` represents a component and requires `Welcome` to be in scope.
90+
>Azokat a komponenseket amik kisbetűvel kezdődnek, a React szimpla DOM címkékként kezeli. Például a `<div />` egy HTML div címkét képvisel, de a `<Welcome />` egy komponenst, és szükséges, hogy a `Welcome` a hatókörben legyen.
9191
>
92-
>To learn more about the reasoning behind this convention, please read [JSX In Depth](/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized).
92+
>Ha többet szeretnél megtudni ezen közös megegyezés mögötti érvelésről, olvasd el a [JSX-ről mélyebben](/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized) részt.
9393
94-
## Composing Components {#composing-components}
94+
## Komponensek komponálása {#composing-components}
9595

96-
Components can refer to other components in their output. This lets us use the same component abstraction for any level of detail. A button, a form, a dialog, a screen: in React apps, all those are commonly expressed as components.
96+
A komponensek utalhatnak más komponensekre is a kimenetükben. Ez lehetővé teszi számunkra, hogy ugyanazt a komponens absztrakciót használjuk bármilyen részletességgel. Egy gomb, egy űrlap, egy dialógus, egy képernyő: React alkalmazásokban ezek általában mind komponensként vannak kifejezve.
9797

98-
For example, we can create an `App` component that renders `Welcome` many times:
98+
Például készíthetünk egy `App` komponenst, ami több `Welcome` komponenst renderel:
9999

100100
```js{8-10}
101101
function Welcome(props) {
102-
return <h1>Hello, {props.name}</h1>;
102+
return <h1>Helló, {props.name}</h1>;
103103
}
104104
105105
function App() {
106106
return (
107107
<div>
108-
<Welcome name="Sara" />
109-
<Welcome name="Cahal" />
110-
<Welcome name="Edite" />
108+
<Welcome name="Sára" />
109+
<Welcome name="Kata" />
110+
<Welcome name="Edit" />
111111
</div>
112112
);
113113
}
@@ -120,13 +120,13 @@ ReactDOM.render(
120120

121121
[](codepen://components-and-props/composing-components)
122122

123-
Typically, new React apps have a single `App` component at the very top. However, if you integrate React into an existing app, you might start bottom-up with a small component like `Button` and gradually work your way to the top of the view hierarchy.
123+
Tipikusan az új React alkalmazásoknak van egy `App` komponensük a legfelsőbb szinten. Azonban ha egy meglévő alkalmazásba integrálod a React-et, dolgozhatsz lentről felfelé fokozatosan haladva, kezdve kis komponensekkel, mint egy `Button` amíg el nem éred a nézet hierarchia csúcsát.
124124

125-
## Extracting Components {#extracting-components}
125+
## Komponensek kivonása {#extracting-components}
126126

127-
Don't be afraid to split components into smaller components.
127+
Ne félj a komponenseket kisebb komponensekké feldarabolni.
128128

129-
For example, consider this `Comment` component:
129+
Vedd ezt a `Comment` komponenst példának:
130130

131131
```js
132132
function Comment(props) {
@@ -154,11 +154,11 @@ function Comment(props) {
154154

155155
[](codepen://components-and-props/extracting-components)
156156

157-
It accepts `author` (an object), `text` (a string), and `date` (a date) as props, and describes a comment on a social media website.
157+
Ez fogad egy `author` (objektumot), `text` (karakterláncot), és `date` (dátumot) props-ként, és egy kommentet ír le egy közösségi média weblapon.
158158

159-
This component can be tricky to change because of all the nesting, and it is also hard to reuse individual parts of it. Let's extract a few components from it.
159+
Ezt a komponenst furfangos lehet megváltoztatni a sok egymásba ágyazás miatt, és nehéz is újra felhasználni az egyedülálló részeit. Vonjunk ki egy pár komponenst belőle.
160160

161-
First, we will extract `Avatar`:
161+
Először is kivonjuk az `Avatar` komponenst:
162162

163163
```js{3-6}
164164
function Avatar(props) {
@@ -171,11 +171,11 @@ function Avatar(props) {
171171
}
172172
```
173173

174-
The `Avatar` doesn't need to know that it is being rendered inside a `Comment`. This is why we have given its prop a more generic name: `user` rather than `author`.
174+
Az `Avatar`-nak nem kell tudnia, hogy mit is renderelünk a `Comment`-ben. Ezért is adtunk a prop-jának egy általánosabb nevet mint a `user`, az `author` helyett.
175175

176-
We recommend naming props from the component's own point of view rather than the context in which it is being used.
176+
Ajánljuk a prop-ok elnevezését a komponens saját szemszögéből nézve, a kontextus helyett amiben az használva van.
177177

178-
We can now simplify `Comment` a tiny bit:
178+
Most egy kicsit tudunk egyszerűsíteni a `Comment` komponensen:
179179

180180
```js{5}
181181
function Comment(props) {
@@ -198,7 +198,7 @@ function Comment(props) {
198198
}
199199
```
200200

201-
Next, we will extract a `UserInfo` component that renders an `Avatar` next to the user's name:
201+
A következőben kivonjuk a `UserInfo` komponenst ami az `Avatar`-t rendereli a felhasználó neve mellett:
202202

203203
```js{3-8}
204204
function UserInfo(props) {
@@ -213,7 +213,7 @@ function UserInfo(props) {
213213
}
214214
```
215215

216-
This lets us simplify `Comment` even further:
216+
Ez tovább egyszerűsíti a `Comment` komponensünket:
217217

218218
```js{4}
219219
function Comment(props) {
@@ -233,30 +233,30 @@ function Comment(props) {
233233

234234
[](codepen://components-and-props/extracting-components-continued)
235235

236-
Extracting components might seem like grunt work at first, but having a palette of reusable components pays off in larger apps. A good rule of thumb is that if a part of your UI is used several times (`Button`, `Panel`, `Avatar`), or is complex enough on its own (`App`, `FeedStory`, `Comment`), it is a good candidate to be a reusable component.
236+
A komponensek kivonása elsőre morgós munkának tűnhet, de nagyobb alkalmazások esetén gyorsan megtérül ha egy újrafelhasználható komponens palettával rendelkezünk. Egy jó ökölszabály ha a felhasználói kezelőfelületed valamelyik része többször fel van használva (`Button`, `Panel`, `Avatar`), vagy elég bonyolult saját magában is (`App`, `FeedStory`, `Comment`) akkor jó jelölt lehet egy újrafelhasználható komponensnek.
237237

238-
## Props are Read-Only {#props-are-read-only}
238+
## A prop-ok csak olvashatók {#props-are-read-only}
239239

240-
Whether you declare a component [as a function or a class](#function-and-class-components), it must never modify its own props. Consider this `sum` function:
240+
Függetlenül hogy egy komponenst [függvényként vagy osztályként](#function-and-class-components) deklarálsz, az soha nem módosíthatja annak saját prop-jait. Vedd ezt a `sum` függvényt:
241241

242242
```js
243243
function sum(a, b) {
244244
return a + b;
245245
}
246246
```
247247

248-
Such functions are called ["pure"](https://en.wikipedia.org/wiki/Pure_function) because they do not attempt to change their inputs, and always return the same result for the same inputs.
248+
Egy ilyen függvényt ["tiszta"](https://hu.wikipedia.org/wiki/Tiszta_függvény) függvénynek nevezünk, mert nem kísérli meg megváltoztatni a bemenetét, és mindig ugyanazt az eredményt adja ugyanazon bemenet esetében.
249249

250-
In contrast, this function is impure because it changes its own input:
250+
Összehasonlításképpen ez a függvény nem tiszta, mert megváltoztatja a saját bemenetét:
251251

252252
```js
253253
function withdraw(account, amount) {
254254
account.total -= amount;
255255
}
256256
```
257257

258-
React is pretty flexible but it has a single strict rule:
258+
A React elég rugalmas, de van egy szigorú szabálya:
259259

260-
**All React components must act like pure functions with respect to their props.**
260+
**Minden React komponensnek tiszta függvényként kell viselkednie annak prop-jaira tekintettel**
261261

262-
Of course, application UIs are dynamic and change over time. In the [next section](/docs/state-and-lifecycle.html), we will introduce a new concept of "state". State allows React components to change their output over time in response to user actions, network responses, and anything else, without violating this rule.
262+
Természetesen az alkalmazások felhasználói felületei dinamikusak és idővel változnak. A [következő fejezetben](/docs/state-and-lifecycle.html) bemutatunk egy új koncepciót, az állapotot, vagyis a "state"-t. A állapotok lehetővé teszik a React komponenseknek hogy idővel megváltoztassák a kimenetüket a felhasználó interakciói, hálózati válaszok, vagy bármi más esetén, anélkül, hogy ezt a szabályt megszegnénk.

0 commit comments

Comments
 (0)