` DOM noodi lisätään näytölle, React kutsuu `ref` callbackia DOM `node` argumentilla. Kun `
` DOM noodi poistetaan, React kutsuu `ref` callbackia `null` argumentilla.
-React will also call your `ref` callback whenever you pass a *different* `ref` callback. In the above example, `(node) => { ... }` is a different function on every render. When your component re-renders, the *previous* function will be called with `null` as the argument, and the *next* function will be called with the DOM node.
+React kutsuu myös `ref` callbackia aina kun välität *erilaisen* `ref` callbackin. Yllä olevassa esimerkissä, `(node) => { ... }` on eri funktio joka renderöinnillä. Kun komponenttisi renderöidään uudelleen, *edellinen* funktio kutsutaan `null` argumentilla, ja *seuraava* funktio kutsutaan DOM nodella.
#### Parametrit {/*ref-callback-parameters*/}
-* `node`: A DOM node or `null`. React will pass you the DOM node when the ref gets attached, and `null` when the ref gets detached. Unless you pass the same function reference for the `ref` callback on every render, the callback will get temporarily detached and re-attached during every re-render of the component.
+* `node`: DOM noodi tai `null`. React välittää DOM noden kun ref liitetään, ja `null` kun ref irrotetaan. Ellei välitä samaa funktiota `ref` callbackiin joka renderöinnillä, callback irrotetaan ja liitetään uudelleen jokaisella komponentin renderöinnillä.
#### Palautukset {/*returns*/}
-Do not return anything from the `ref` callback.
+Ei palauta mitään `ref` callbackista.
---
-### React event object {/*react-event-object*/}
+### React tapahtumaolio {/*react-event-object*/}
-Your event handlers will receive a *React event object.* It is also sometimes known as a "synthetic event".
+Tapahtumakäsittelijäsi vastaanottaa *React tapahtumaolion*. Sitä kutsutaan myös joskus "synteettiseksi tapahtumaksi".
```js
{
- console.log(e); // React event object
+ console.log(e); // React tapahtumaolio
}} />
```
-It conforms to the same standard as the underlying DOM events, but fixes some browser inconsistencies.
+Se noudattaa samaa standardia kuin taustalla olevat DOM tapahtumat, mutta korjaa joitain selaimen epäjohdonmukaisuuksia.
-Some React events do not map directly to the browser's native events. For example in `onMouseLeave`, `e.nativeEvent` will point to a `mouseout` event. The specific mapping is not part of the public API and may change in the future. If you need the underlying browser event for some reason, read it from `e.nativeEvent`.
+Jotkin React tapahtumat eivät mäppäydy suoraan selaimen alkuperäisiin tapahtumiin. Esimerkiksi `onMouseLeave`, `e.nativeEvent` osoittaa `mouseout` tapahtumaan. Tämä mäppäys ei ole osa julkista API:a ja saattaa muuttua tulevaisuudessa. Jos tarvitset taustalla olevan selaimen tapahtuman jostain syystä, lue se `e.nativeEvent` kautta.
-#### Properties {/*react-event-object-properties*/}
+#### Ominaisuudet {/*react-event-object-properties*/}
-React event objects implement some of the standard [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) properties:
+React tapahtumaolio toteuttaa joitain standardin [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) ominaisuuksia:
-* [`bubbles`](https://developer.mozilla.org/en-US/docs/Web/API/Event/bubbles): A boolean. Returns whether the event bubbles through the DOM.
-* [`cancelable`](https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable): A boolean. Returns whether the event can be canceled.
-* [`currentTarget`](https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget): A DOM node. Returns the node to which the current handler is attached in the React tree.
-* [`defaultPrevented`](https://developer.mozilla.org/en-US/docs/Web/API/Event/defaultPrevented): A boolean. Returns whether `preventDefault` was called.
-* [`eventPhase`](https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase): A number. Returns which phase the event is currently in.
-* [`isTrusted`](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted): A boolean. Returns whether the event was initiated by user.
-* [`target`](https://developer.mozilla.org/en-US/docs/Web/API/Event/target): A DOM node. Returns the node on which the event has occurred (which could be a distant child).
-* [`timeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp): A number. Returns the time when the event occurred.
+* [`bubbles`](https://developer.mozilla.org/en-US/docs/Web/API/Event/bubbles): Totuusarvo. Palauttaa kupliiko tapahtuma DOMin läpi.
+* [`cancelable`](https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable): Totuusarvo. Palauttaa voiko tapahtuman peruuttaa.
+* [`currentTarget`](https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget): DOM noodi. Palauttaa noodin johon nykyinen käsittelijä on liitetty React puussa.
+* [`defaultPrevented`](https://developer.mozilla.org/en-US/docs/Web/API/Event/defaultPrevented): Totuusarvo. Palauttaa onko `preventDefault` kutsuttu.
+* [`eventPhase`](https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase): Numero. Palauttaa missä vaiheessa tapahtuma on tällä hetkellä.
+* [`isTrusted`](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted): Totuusarvo. Palauttaa onko tapahtuma käyttäjän aloittama.
+* [`target`](https://developer.mozilla.org/en-US/docs/Web/API/Event/target): DOM noodi. Palauttaa noodin jossa tapahtuma on tapahtunut (joka voi olla kaukainen lapsi).
+* [`timeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp): Numero. Palauttaa ajan jolloin tapahtuma tapahtui.
-Additionally, React event objects provide these properties:
+Lisäksi, React tapahtumaoliot tarjoavat nämä ominaisuudet:
-* `nativeEvent`: A DOM [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). The original browser event object.
+* `nativeEvent`: DOM [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). Alkuperäinen selaimen tapahtumaolio.
-#### Methods {/*react-event-object-methods*/}
+#### Metodit {/*react-event-object-methods*/}
-React event objects implement some of the standard [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) methods:
+React tapahtumaolio toteuttaa joitain standardin [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) metodeista:
-* [`preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault): Prevents the default browser action for the event.
-* [`stopPropagation()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation): Stops the event propagation through the React tree.
+* [`preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault): Estää tapahtuman oletustoiminnon.
+* [`stopPropagation()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation): Estää tapahtuman kuplimisen React puussa.
-Additionally, React event objects provide these methods:
+Lisäksi, React tapahtumaoliot tarjoavat nämä metodit:
-* `isDefaultPrevented()`: Returns a boolean value indicating whether `preventDefault` was called.
-* `isPropagationStopped()`: Returns a boolean value indicating whether `stopPropagation` was called.
-* `persist()`: Not used with React DOM. With React Native, call this to read event's properties after the event.
-* `isPersistent()`: Not used with React DOM. With React Native, returns whether `persist` has been called.
+* `isDefaultPrevented()`: Palauttaa totuusarvon joka kertoo onko `preventDefault` kutsuttu.
+* `isPropagationStopped()`: Palauttaa totuusarvon joka kertoo onko `stopPropagation` kutsuttu.
+* `persist()`: Ei käytetä React DOMin kanssa. React Nativella, kutsu tätä lukeaksesi tapahtuman ominaisuudet tapahtuman jälkeen.
+* `isPersistent()`: Ei käytetä React DOMin kanssa. React Nativella, palauttaa onko `persist` kutsuttu.
#### Rajoitukset {/*react-event-object-caveats*/}
-* The values of `currentTarget`, `eventPhase`, `target`, and `type` reflect the values your React code expects. Under the hood, React attaches event handlers at the root, but this is not reflected in React event objects. For example, `e.currentTarget` may not be the same as the underlying `e.nativeEvent.currentTarget`. For polyfilled events, `e.type` (React event type) may differ from `e.nativeEvent.type` (underlying type).
+* `currentTarget`, `eventPhase`, `target`, ja `type` arvot heijastaa arvoja, joita React koodisi olettaa. Taustalla, React liittää tapahtumakäsittelijät juureen, mutta tätä ei heijasteta React tapahtumaolioissa. Esimerkiksi, `e.currentTarget` ei välttämättä ole sama kuin taustalla oleva `e.nativeEvent.currentTarget`. Polyfillatuissa tapahtumissa, `e.type` (React tapahtuman tyyppi) voi erota `e.nativeEvent.type` (taustalla oleva tyyppi).
---
-### `AnimationEvent` handler function {/*animationevent-handler*/}
+### `AnimationEvent` käsittelijäfunktio {/*animationevent-handler*/}
-An event handler type for the [CSS animation](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations) events.
+Tapahtumakäsittelijätyyppi [CSS animaatioiden](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations) -tapahtumiin.
```js
@@ -387,7 +387,7 @@ An event handler type for the [HTML Drag and Drop API](https://developer.mozilla
onDragStart={e => console.log('onDragStart')}
onDragEnd={e => console.log('onDragEnd')}
>
- Drag source
+ Drag lähde
{ e.preventDefault(); console.log('onDragOver'); }}
onDrop={e => console.log('onDrop')}
>
- Drop target
+ Drop kohde
>
```
#### Parametrit {/*dragevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`DragEvent`](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent) properties:
+* `e`: [React tapahtumaolio](#react-event-object) näillä ylimääräisillä [`DragEvent`](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent) ominaisuuksilla:
* [`dataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/dataTransfer)
- It also includes the inherited [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) properties:
+ Sisältää myös perityt [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) ominaisuudet:
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey)
* [`button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)
@@ -425,16 +425,16 @@ An event handler type for the [HTML Drag and Drop API](https://developer.mozilla
* [`screenY`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY)
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ Sisältää myös perityt [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) ominaisuudet:
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `FocusEvent` handler function {/*focusevent-handler*/}
+### `FocusEvent` käsittelijäfunktio {/*focusevent-handler*/}
-An event handler type for the focus events.
+Tapahtumakäsittelijätyyppi kohdistumisen tapahtumiin.
```js
```
-[See an example.](#handling-focus-events)
+[Katso esimerkki.](#handling-focus-events)
#### Parametrit {/*focusevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`FocusEvent`](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent) properties:
+* `e`: [React tapahtumaolio](#react-event-object) näillä ylimääräisillä [`FocusEvent`](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent) ominaisuuksilla:
* [`relatedTarget`](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/relatedTarget)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ Sisältää myös perityt [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) ominaisuudet:
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `Event` handler function {/*event-handler*/}
+### `Event` käsittelijäfunktio {/*event-handler*/}
-An event handler type for generic events.
+Tapahtumakäsittelijätyyppi yleisiin tapahtumiin.
#### Parametrit {/*event-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with no additional properties.
+* `e`: [React tapahtumaolio](#react-event-object) ilman ylimääräisiä ominaisuuksia.
---
-### `InputEvent` handler function {/*inputevent-handler*/}
+### `InputEvent` käsittelijäfunktio {/*inputevent-handler*/}
-An event handler type for the `onBeforeInput` event.
+Tapahtumakäsittelijätyyppi `onBeforeInput` tapahtumalle.
```js
console.log('onBeforeInput')} />
@@ -477,14 +477,14 @@ An event handler type for the `onBeforeInput` event.
#### Parametrit {/*inputevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`InputEvent`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent) properties:
+* `e`: [React tapahtumaolio](#react-event-object) näillä ylimääräisillä [`InputEvent`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent) ominaisuuksilla:
* [`data`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/data)
---
-### `KeyboardEvent` handler function {/*keyboardevent-handler*/}
+### `KeyboardEvent` käsittelijäfunktio {/*keyboardevent-handler*/}
-An event handler type for keyboard events.
+Tapahtumakäsittelijätyyppi näppäimistötapahtumiin.
```js
```
-[See an example.](#handling-keyboard-events)
+[Katso esimerkki.](#handling-keyboard-events)
#### Parametrit {/*keyboardevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) properties:
+* `e`: [React tapahtumaolio](#react-event-object) näillä ylimääräisillä [`KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) ominaisuuksilla:
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/altKey)
* [`charCode`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode)
* [`code`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
@@ -512,16 +512,16 @@ An event handler type for keyboard events.
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/shiftKey)
* [`which`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ Sisältää myös perityt [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) ominaisuudet:
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `MouseEvent` handler function {/*mouseevent-handler*/}
+### `MouseEvent` käsittelijäfunktio {/*mouseevent-handler*/}
-An event handler type for mouse events.
+Tapahtumakäsittelijätyyppi hiiritapahtumiin.
```js
```
-[See an example.](#handling-mouse-events)
+[Katso esimerkki.](#handling-mouse-events)
#### Parametrit {/*mouseevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) properties:
+* `e`: [React tapahtumaolio](#react-event-object) näillä ylimääräisillä [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) ominaisuuksilla:
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey)
* [`button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)
* [`buttons`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons)
@@ -556,16 +556,16 @@ An event handler type for mouse events.
* [`screenY`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY)
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ Sisältää myös perityt [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) ominaisuudet:
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `PointerEvent` handler function {/*pointerevent-handler*/}
+### `PointerEvent` käsittelijäfunktio {/*pointerevent-handler*/}
-An event handler type for [pointer events.](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events)
+Tapahtumakäisttelijätyyppi [osoitintapahtumiin.](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events)
```js
```
-[See an example.](#handling-pointer-events)
+[Katso esimerkki.](#handling-pointer-events)
#### Parametrit {/*pointerevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent) properties:
+* `e`: [React tapahtumaolio](#react-event-object) näillä ylimääräisillä [`PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent) ominaisuuksilla:
* [`height`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height)
* [`isPrimary`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary)
* [`pointerId`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId)
@@ -593,7 +593,7 @@ An event handler type for [pointer events.](https://developer.mozilla.org/en-US/
* [`twist`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/twist)
* [`width`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width)
- It also includes the inherited [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) properties:
+ Sisältää myös perityt [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) ominaisuudet:
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey)
* [`button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)
@@ -612,16 +612,16 @@ An event handler type for [pointer events.](https://developer.mozilla.org/en-US/
* [`screenY`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY)
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ Sisältää myös perityt [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) ominaisuudet:
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `TouchEvent` handler function {/*touchevent-handler*/}
+### `TouchEvent` käsittelijäfunktio {/*touchevent-handler*/}
-An event handler type for [touch events.](https://developer.mozilla.org/en-US/docs/Web/API/Touch_events)
+Tapahtumakäsittelijätyyppi [kosketustapahtumiin.](https://developer.mozilla.org/en-US/docs/Web/API/Touch_events)
```js
```
-Then you write the CSS rules for it in a separate CSS file:
+Sitten kirjoitat CSS säännöt sille erillisessä CSS tiedostossa:
```css
-/* In your CSS */
+/* CSS tiedostossasi */
.avatar {
border-radius: 50%;
}
```
-React does not prescribe how you add CSS files. In the simplest case, you'll add a [` `](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) tag to your HTML. If you use a build tool or a framework, consult its documentation to learn how to add a CSS file to your project.
+React ei määrää miten lisäät CSS tiedostoja. Yksinkertaisimmassa tapauksessa, lisäät [` `](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) tagin HTML:ään. Jos käytät rakennustyökalua tai frameworkkia, tutustu sen dokumentaatioon oppiaksesi miten lisäät CSS tiedoston projektiisi.
-Sometimes, the style values depend on data. Use the `style` attribute to pass some styles dynamically:
+Joskus, tyylien arvot riippuvat datasta. Käytä `style` attribuuttia välittääksesi joitain tyylejä dynaamisesti:
```js {3-6}
@@ -811,13 +811,13 @@ export default function Avatar({ user }) {
-#### How to apply multiple CSS classes conditionally? {/*how-to-apply-multiple-css-classes-conditionally*/}
+#### Miten käyttää useita CSS-luokkia ehdollisesti? {/*how-to-apply-multiple-css-classes-conditionally*/}
-To apply CSS classes conditionally, you need to produce the `className` string yourself using JavaScript.
+Määrittääksesi CSS luokkia ehdollisesti, sinun täytyy tuottaa `className` merkkijono itse käyttäen JavaScriptiä.
-For example, `className={'row ' + (isSelected ? 'selected': '')}` will produce either `className="row"` or `className="row selected"` depending on whether `isSelected` is `true`.
+Esimerkiksi, `className={'row ' + (isSelected ? 'selected': '')}` tuottaa joko `className="row"` tai `className="row selected"` riippuen siitä onko `isSelected` `true`.
-To make this more readable, you can use a tiny helper library like [`classnames`:](https://github.com/JedWatson/classnames)
+Tehdäksesi tästä luettavamman, voit käyttää pientä apukirjastoa kuten [`classnames`:](https://github.com/JedWatson/classnames)
```js
import cn from 'classnames';
@@ -831,7 +831,7 @@ function Row({ isSelected }) {
}
```
-It is especially convenient if you have multiple conditional classes:
+Se on erityisen kätevää jos sinulla on useita ehdollisia luokkia:
```js
import cn from 'classnames';
@@ -853,9 +853,9 @@ function Row({ isSelected, size }) {
---
-### Manipulating a DOM node with a ref {/*manipulating-a-dom-node-with-a-ref*/}
+### DOM elemetin manipuolinti refillä {/*manipulating-a-dom-node-with-a-ref*/}
-Sometimes, you'll need to get the browser DOM node associated with a tag in JSX. For example, if you want to focus an ` ` when a button is clicked, you need to call [`focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the browser ` ` DOM node.
+Joskus sinun täytyy saada selaimen DOM noodi joka on yhdistetty JSX tagiin. Esimerkiksi, jos haluat kohdistaa ` `:iin kun painiketta painetaan, sinun täytyy kutsua [`focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) selaimen ` ` DOM noodilla.
To obtain the browser DOM node for a tag, [declare a ref](/reference/react/useRef) and pass it as the `ref` attribute to that tag:
@@ -870,7 +870,7 @@ export default function Form() {
// ...
```
-React will put the DOM node into `inputRef.current` after it's been rendered to the screen.
+React asettaa DOM noodin `inputRef.current`:iin kun se on renderöity näytölle.
@@ -897,24 +897,24 @@ export default function Form() {
-Read more about [manipulating DOM with refs](/learn/manipulating-the-dom-with-refs) and [check out more examples.](/reference/react/useRef#examples-dom)
+Lue lisää [DOM manipuloinnista refien avulla](/learn/manipulating-the-dom-with-refs) ja [katso lisää esimerkkejä.](/reference/react/useRef#examples-dom)
-For more advanced use cases, the `ref` attribute also accepts a [callback function.](#ref-callback)
+Kehittyneempiin käyttötapauksiin, `ref` attribuutti hyväksyy myös [takaisinkutsufunktion.](#ref-callback)
---
-### Dangerously setting the inner HTML {/*dangerously-setting-the-inner-html*/}
+### Sisäisen HTML sisällön asettaminen vaarallisesti {/*dangerously-setting-the-inner-html*/}
-You can pass a raw HTML string to an element like so:
+Voit välittää raakaa HTML merkkijonoa elementille näin:
```js
const markup = { __html: 'some raw html
' };
return
;
```
-**This is dangerous. As with the underlying DOM [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) property, you must exercise extreme caution! Unless the markup is coming from a completely trusted source, it is trivial to introduce an [XSS](https://en.wikipedia.org/wiki/Cross-site_scripting) vulnerability this way.**
+**Tämä on vaarallista. Kuten DOM:n [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) ominaisuudella, sinun täytyy olla erittäin varovainen! Ellei merkintä tule täysin luotettavasta lähteestä, on triviaalia aiheuttaa [XSS](https://en.wikipedia.org/wiki/Cross-site_scripting) haavoittuvuus tällä tavalla.**
-For example, if you use a Markdown library that converts Markdown to HTML, you trust that its parser doesn't contain bugs, and the user only sees their own input, you can display the resulting HTML like this:
+Esimerkiksi, jos käytät Markdown kirjastoa joka muuntaa Markdownia HTML:ksi, luotat että sen parseri ei sisällä bugeja, ja käyttäjä näkee vain oman syötteen, voit näyttää tuloksena olevan HTML:n näin:
@@ -946,9 +946,9 @@ import { Remarkable } from 'remarkable';
const md = new Remarkable();
function renderMarkdownToHTML(markdown) {
- // This is ONLY safe because the output HTML
- // is shown to the same user, and because you
- // trust this Markdown parser to not have bugs.
+ // Tämä on turvallista VAIN koska HTML näytetään
+ // samalle käyttäjälle, ja koska luotat tämän
+ // Markdown parserin oelvan bugivapaa.
const renderedHTML = md.render(markdown);
return {__html: renderedHTML};
}
@@ -982,28 +982,28 @@ textarea { display: block; margin-top: 5px; margin-bottom: 10px; }
-To see why rendering arbitrary HTML is dangerous, replace the code above with this:
+Nähdäksesi miksi mielivaltaisen HTML renderöiminen on vaarallista, korvaa ylläoleva koodi tällä:
```js {1-4,7,8}
const post = {
- // Imagine this content is stored in the database.
- content: ` `
+ // Kuvittele tämä sisältö tallennettuna tietokantaan.
+ content: ` `
};
export default function MarkdownPreview() {
- // 🔴 SECURITY HOLE: passing untrusted input to dangerouslySetInnerHTML
+ // 🔴 TIETOTURVA-AUKKO: luotettamattoman syötteen välittäminen dangerouslySetInnerHTML:lle
const markup = { __html: post.content };
return
;
}
```
-The code embedded in the HTML will run. A hacker could use this security hole to steal user information or to perform actions on their behalf. **Only use `dangerouslySetInnerHTML` with trusted and sanitized data.**
+Koodi upotettuna HTML:ssä suoritetaan. Hakkeri voisi käyttää tätä tietoturva-aukkoa varastaakseen käyttäjän tietoja tai suorittaakseen toimia heidän puolestaan. **Käytä `dangerouslySetInnerHTML`:ää vain luotettavan ja puhdistetun datan kanssa.**
---
-### Handling mouse events {/*handling-mouse-events*/}
+### Hiiren tapahtumien käsitteleminen {/*handling-mouse-events*/}
-This example shows some common [mouse events](#mouseevent-handler) and when they fire.
+Tämä esimerkki näyttää joitain yleisiä [hiiritapahtumia](#mouseevent-handler) ja milloin ne suoritetaan.
@@ -1015,24 +1015,24 @@ export default function MouseExample() {
onMouseLeave={e => console.log('onMouseLeave (parent)')}
>
console.log('onClick (first button)')}
- onMouseDown={e => console.log('onMouseDown (first button)')}
- onMouseEnter={e => console.log('onMouseEnter (first button)')}
- onMouseLeave={e => console.log('onMouseLeave (first button)')}
- onMouseOver={e => console.log('onMouseOver (first button)')}
- onMouseUp={e => console.log('onMouseUp (first button)')}
+ onClick={e => console.log('onClick (ensimmäinen painike)')}
+ onMouseDown={e => console.log('onMouseDown (ensimmäinen painike)')}
+ onMouseEnter={e => console.log('onMouseEnter (ensimmäinen painike)')}
+ onMouseLeave={e => console.log('onMouseLeave (ensimmäinen painike)')}
+ onMouseOver={e => console.log('onMouseOver (ensimmäinen painike)')}
+ onMouseUp={e => console.log('onMouseUp (ensimmäinen painike)')}
>
- First button
+ Ensimmäinen painike
console.log('onClick (second button)')}
- onMouseDown={e => console.log('onMouseDown (second button)')}
- onMouseEnter={e => console.log('onMouseEnter (second button)')}
- onMouseLeave={e => console.log('onMouseLeave (second button)')}
- onMouseOver={e => console.log('onMouseOver (second button)')}
- onMouseUp={e => console.log('onMouseUp (second button)')}
+ onClick={e => console.log('onClick (toinen painike)')}
+ onMouseDown={e => console.log('onMouseDown (toinen painike)')}
+ onMouseEnter={e => console.log('onMouseEnter (toinen painike)')}
+ onMouseLeave={e => console.log('onMouseLeave (toinen painike)')}
+ onMouseOver={e => console.log('onMouseOver (toinen painike)')}
+ onMouseUp={e => console.log('onMouseUp (toinen painike)')}
>
- Second button
+ Toinen painike
);
@@ -1048,9 +1048,9 @@ input { margin-left: 10px; }
---
-### Handling pointer events {/*handling-pointer-events*/}
+### Osoittimen tapahtumien käsitteleminen {/*handling-pointer-events*/}
-This example shows some common [pointer events](#pointerevent-handler) and when they fire.
+Tämä esimerkki näyttää joitain yleisiä [osoitintapahtumia](#pointerevent-handler) ja milloin ne suoritetaan.
@@ -1063,24 +1063,24 @@ export default function PointerExample() {
style={{ padding: 20, backgroundColor: '#ddd' }}
>
console.log('onPointerDown (first child)')}
- onPointerEnter={e => console.log('onPointerEnter (first child)')}
- onPointerLeave={e => console.log('onPointerLeave (first child)')}
- onPointerMove={e => console.log('onPointerMove (first child)')}
- onPointerUp={e => console.log('onPointerUp (first child)')}
+ onPointerDown={e => console.log('onPointerDown (ensimmäinen lapsi)')}
+ onPointerEnter={e => console.log('onPointerEnter (ensimmäinen lapsi)')}
+ onPointerLeave={e => console.log('onPointerLeave (ensimmäinen lapsi)')}
+ onPointerMove={e => console.log('onPointerMove (ensimmäinen lapsi)')}
+ onPointerUp={e => console.log('onPointerUp (ensimmäinen lapsi)')}
style={{ padding: 20, backgroundColor: 'lightyellow' }}
>
- First child
+ Ensimmäinen lapsi
console.log('onPointerDown (second child)')}
- onPointerEnter={e => console.log('onPointerEnter (second child)')}
- onPointerLeave={e => console.log('onPointerLeave (second child)')}
- onPointerMove={e => console.log('onPointerMove (second child)')}
- onPointerUp={e => console.log('onPointerUp (second child)')}
+ onPointerDown={e => console.log('onPointerDown (toinen lapsi)')}
+ onPointerEnter={e => console.log('onPointerEnter (toinen lapsi)')}
+ onPointerLeave={e => console.log('onPointerLeave (toinen lapsi)')}
+ onPointerMove={e => console.log('onPointerMove (toinen lapsi)')}
+ onPointerUp={e => console.log('onPointerUp (toinen lapsi)')}
style={{ padding: 20, backgroundColor: 'lightblue' }}
>
- Second child
+ Toinen lapsi
);
@@ -1096,9 +1096,9 @@ input { margin-left: 10px; }
---
-### Handling focus events {/*handling-focus-events*/}
+### Kohdennustapahtumien käsitteleminen {/*handling-focus-events*/}
-In React, [focus events](#focusevent-handler) bubble. You can use the `currentTarget` and `relatedTarget` to differentiate if the focusing or blurring events originated from outside of the parent element. The example shows how to detect focusing a child, focusing the parent element, and how to detect focus entering or leaving the whole subtree.
+Reactissa, [kohdennustapahtumat](#focusevent-handler) kuplivat. Voit käyttää `currentTarget` ja `relatedTarget` erottaaksesi onko kohdennus peräisin ulkopuolelta vai ei. Esimerkki näyttää miten havaita lapsen kohdennustapahtuma, vanhemman kohdennustapahtuma, ja miten havaita kohdennuksen tuleminen tai lähteminen koko alipuusta.