Skip to content

Commit e3ed9d4

Browse files
committed
Handling Events page translation
1 parent f66fd9f commit e3ed9d4

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

content/docs/handling-events.md

+37-37
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
11
---
22
id: handling-events
3-
title: Handling Events
3+
title: Események kezelése
44
permalink: docs/handling-events.html
55
prev: state-and-lifecycle.html
66
next: conditional-rendering.html
77
redirect_from:
88
- "docs/events-ko-KR.html"
99
---
1010

11-
Handling events with React elements is very similar to handling events on DOM elements. There are some syntactic differences:
11+
A React elemek eseményeinek kezelése nagyon hasonló a DOM elemek eseménykezeléséhez. Viszont van néhány szintaktikus különbség:
1212

13-
* React events are named using camelCase, rather than lowercase.
14-
* With JSX you pass a function as the event handler, rather than a string.
13+
* A React események elnevezésére camelCase-t használunk kisbetűk helyett.
14+
* A JSX-ben string helyett függvényt adunk át az eseménykezelőnek.
1515

16-
For example, the HTML:
16+
Például ez a HTML:
1717

1818
```html
1919
<button onclick="activateLasers()">
20-
Activate Lasers
20+
Lézerek aktiválása
2121
</button>
2222
```
2323

24-
is slightly different in React:
24+
kissé máshogyan néz ki Reactben:
2525

2626
```js{1}
2727
<button onClick={activateLasers}>
28-
Activate Lasers
28+
Lézerek aktiválása
2929
</button>
3030
```
3131

32-
Another difference is that you cannot return `false` to prevent default behavior in React. You must call `preventDefault` explicitly. For example, with plain HTML, to prevent the default link behavior of opening a new page, you can write:
32+
Egy másik különbség, hogy nem tudsz `false` értéket visszaadni, hogy megakadályozd a default viselkedést Reactben. Expliciten meg kell hívni a `preventDefault`-ot. Például szimpla HTML-ben ahhoz, hogy megakadályozzuk egy linknek a default viselkedését, ezt írhatjuk:
3333

3434
```html
35-
<a href="#" onclick="console.log('The link was clicked.'); return false">
36-
Click me
35+
<a href="#" onclick="console.log('Rákattintottak a linkre.'); return false">
36+
Kattints rám
3737
</a>
3838
```
3939

40-
In React, this could instead be:
41-
40+
Reactben ez így nézne ki:
41+
****
4242
```js{2-5,8}
4343
function ActionLink() {
4444
function handleClick(e) {
4545
e.preventDefault();
46-
console.log('The link was clicked.');
46+
console.log('Rákattintottak a linkre.');
4747
}
4848
4949
return (
5050
<a href="#" onClick={handleClick}>
51-
Click me
51+
Kattints rám
5252
</a>
5353
);
5454
}
5555
```
5656

57-
Here, `e` is a synthetic event. React defines these synthetic events according to the [W3C spec](https://www.w3.org/TR/DOM-Level-3-Events/), so you don't need to worry about cross-browser compatibility. See the [`SyntheticEvent`](/docs/events.html) reference guide to learn more.
57+
Itt az `e` egy szintetikus esemény. A React ezeket a szintetikus eseményeket a [W3C specifikáció](https://www.w3.org/TR/DOM-Level-3-Events/) alapján definiálja, emiatt nem kell a böngészők közötti kompatibilitással törődnöd. Lásd a [`SyntheticEvent`](/docs/events.html) referenciát, ha többet szeretnél megtudni erről.
5858

59-
When using React, you generally don't need to call `addEventListener` to add listeners to a DOM element after it is created. Instead, just provide a listener when the element is initially rendered.
59+
Reactben általában nem kell meghívnod az `addEventListener`-t hogy eseménykezelőket adj hozzá egy DOM elemhez miután az létrejött. Ehelyett szimplán akkor add hozzá, amikor az elem először renderelődik.
6060

61-
When you define a component using an [ES6 class](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes), a common pattern is for an event handler to be a method on the class. For example, this `Toggle` component renders a button that lets the user toggle between "ON" and "OFF" states:
61+
Amikor egy komponenst [ES6 osztályként](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) definiálsz, az eseménykezelő általában egy függvény az adott osztályban. Például ez a `Toggle` komponens egy gombot renderel, ami az "ON" és "OFF" közötti kapcsolást teszi lehetővé a felhasználó számára:
6262

6363
```js{6,7,10-14,18}
6464
class Toggle extends React.Component {
6565
constructor(props) {
6666
super(props);
6767
this.state = {isToggleOn: true};
6868
69-
// This binding is necessary to make `this` work in the callback
69+
// Ez a kötés(binding) szükséges a `this` használatához a callbackben
7070
this.handleClick = this.handleClick.bind(this);
7171
}
7272
@@ -91,35 +91,35 @@ ReactDOM.render(
9191
);
9292
```
9393

94-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/xEmzGg?editors=0010)
94+
[**Próbáld ki CodePenen**](https://codepen.io/gaearon/pen/xEmzGg?editors=0010)
9595

96-
You have to be careful about the meaning of `this` in JSX callbacks. In JavaScript, class methods are not [bound](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind) by default. If you forget to bind `this.handleClick` and pass it to `onClick`, `this` will be `undefined` when the function is actually called.
96+
Vigyázni kell a `this` használatával a JSX callbackekben. JavaScriptben az osztálymetódusok alapesetben nincsenek [hozzákötve](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind) a `this`-hez. Ha elfelejtenéd hozzákötni a `this.handleClick`-et a `this`-hez és így rendeled hozzá az `onClick`-hez, a `this` `undefined` értékű lesz amikor a metódus meghívódik.
9797

98-
This is not React-specific behavior; it is a part of [how functions work in JavaScript](https://www.smashingmagazine.com/2014/01/understanding-javascript-function-prototype-bind/). Generally, if you refer to a method without `()` after it, such as `onClick={this.handleClick}`, you should bind that method.
98+
Ez nem React-specifikus viselkedés, hanem alapvetően [így működnek a függvények JavaScriptben](https://www.smashingmagazine.com/2014/01/understanding-javascript-function-prototype-bind/). Általában, ha egy metódusra a `()` nélkül hivatkozol, például `onClick={this.handleClick}`, hozzá kell kötnöd ezt a metódust a `this`-hez.
9999

100-
If calling `bind` annoys you, there are two ways you can get around this. If you are using the experimental [public class fields syntax](https://babeljs.io/docs/plugins/transform-class-properties/), you can use class fields to correctly bind callbacks:
100+
Ha a `bind` hívás zavar téged, kétféle módon is kikerülheted. Ha a kísérleti [nyilvános osztálymező szintaxist](https://babeljs.io/docs/plugins/transform-class-properties/) használod, a kötéshez osztálymezőket is használhatsz:
101101

102102
```js{2-6}
103103
class LoggingButton extends React.Component {
104-
// This syntax ensures `this` is bound within handleClick.
105-
// Warning: this is *experimental* syntax.
104+
// Ez a szintaxis biztosítja a `this` handleClickhez kötését.
105+
// Vigyázat: ez *kísérleti* szintaxis.
106106
handleClick = () => {
107107
console.log('this is:', this);
108108
}
109109
110110
render() {
111111
return (
112112
<button onClick={this.handleClick}>
113-
Click me
113+
Kattints rám
114114
</button>
115115
);
116116
}
117117
}
118118
```
119119

120-
This syntax is enabled by default in [Create React App](https://github.com/facebookincubator/create-react-app).
120+
Ez a szintaxis alapból be van kapcsolva [Create React App-ban](https://github.com/facebookincubator/create-react-app).
121121

122-
If you aren't using class fields syntax, you can use an [arrow function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) in the callback:
122+
Az osztálymező szintaxis helyett [nyilas metódusokat](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) is használhatsz a callbackben:
123123

124124
```js{7-9}
125125
class LoggingButton extends React.Component {
@@ -128,27 +128,27 @@ class LoggingButton extends React.Component {
128128
}
129129
130130
render() {
131-
// This syntax ensures `this` is bound within handleClick
131+
// Ez a szintaxis biztosítja a `this` handleClickhez való kötését
132132
return (
133133
<button onClick={(e) => this.handleClick(e)}>
134-
Click me
134+
Kattints rám
135135
</button>
136136
);
137137
}
138138
}
139139
```
140140

141-
The problem with this syntax is that a different callback is created each time the `LoggingButton` renders. In most cases, this is fine. However, if this callback is passed as a prop to lower components, those components might do an extra re-rendering. We generally recommend binding in the constructor or using the class fields syntax, to avoid this sort of performance problem.
141+
Az a probléma ezzel a szintaxissal, hogy a `LoggingButton` minden egyes renderelésekor egy új callback hozódik létre. A legtöbb esetben ez nem gond. Viszont ha ezt a callbacket gyerekkomponenseknek adjuk át, azok lehet, hogy még egyszer újrarenderelődnek. Mi általánosságban a konstruktor bindingot vagy az oszálymező szintaxist ajánljuk, hogy elkerüljük az efféle teljesítményproblémákat.
142142

143-
## Passing Arguments to Event Handlers {#passing-arguments-to-event-handlers}
143+
## Argumentumok átadása az eseménykezelőknek {#passing-arguments-to-event-handlers}
144144

145-
Inside a loop, it is common to want to pass an extra parameter to an event handler. For example, if `id` is the row ID, either of the following would work:
145+
Egy cikluson belül gyakori, hogy egy extra paramétert is szeretnénk átadni egy eseménykezelőnek. Például ha `id` a sor azonosítója, a következők bármelyike működhet:
146146

147147
```js
148-
<button onClick={(e) => this.deleteRow(id, e)}>Delete Row</button>
149-
<button onClick={this.deleteRow.bind(this, id)}>Delete Row</button>
148+
<button onClick={(e) => this.deleteRow(id, e)}>Sor törlése</button>
149+
<button onClick={this.deleteRow.bind(this, id)}>Sor törlése</button>
150150
```
151151

152-
The above two lines are equivalent, and use [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) and [`Function.prototype.bind`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind) respectively.
152+
A fenti két sor ekvivalens, és sorrendben [nyilas függvényeket](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) és [`Function.prototype.bind`-ot](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind) használnak.
153153

154-
In both cases, the `e` argument representing the React event will be passed as a second argument after the ID. With an arrow function, we have to pass it explicitly, but with `bind` any further arguments are automatically forwarded.
154+
Mindkét esetben az `e` argumentum, ami a React eseményt reprezentálja, az ID után egy második paraméterként lesz átadva. A nyilas függvénnyel explicit módon adjuk át, viszont a `bind` használatával minden további argumentum automatikusan átadódik.

0 commit comments

Comments
 (0)