Skip to content

Commit 50608be

Browse files
authored
Merge branch 'main' into sync-68f417a6
2 parents 7a915cd + 9b9a51b commit 50608be

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

src/components/MDX/Sandpack/DownloadButton.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*/
44

5-
<<<<<<< HEAD
6-
import {useSandpack} from '@codesandbox/sandpack-react';
7-
import {useSyncExternalStore} from 'react';
8-
=======
95
import {useSyncExternalStore} from 'react';
106
import {useSandpack} from '@codesandbox/sandpack-react/unstyled';
11-
>>>>>>> 68f417a600c7d7b8c4131e39f8a843a856ae3909
127
import {IconDownload} from '../../Icon/IconDownload';
138
export interface DownloadButtonProps {}
149

src/content/reference/react/Fragment.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: <Fragment> (<>...</>)
44

55
<Intro>
66

7-
`<Fragment>`, often used via `<>...</>` syntax, lets you group elements without a wrapper node.
7+
`<Fragment>`, useiten käytetty `<></>` syntaksin kautta, antaa sinun ryhmitellä elementtejä ilman wrapper-elementtiä.
88

99
```js
1010
<>
@@ -23,25 +23,25 @@ title: <Fragment> (<>...</>)
2323

2424
### `<Fragment>` {/*fragment*/}
2525

26-
Wrap elements in `<Fragment>` to group them together in situations where you need a single element. Grouping elements in `Fragment` has no effect on the resulting DOM; it is the same as if the elements were not grouped. The empty JSX tag `<></>` is shorthand for `<Fragment></Fragment>` in most cases.
26+
Kääri elementtejä `<Fragment>`:n sisään ryhmitelläksesi ne yhteen tilanteissa, joissa tarvitset yhden elementin. Elementtien ryhmittely `Fragment`:n sisään ei vaikuta lopulliseen DOM:iin; se on sama kuin elementtejä ei oltaisi ryhmitelty. Tyhjä JSX-tagi `<></>` on lyhenne `<Fragment></Fragment>`:sta useimmissa tapauksissa.
2727

2828
#### Propsit {/*props*/}
2929

30-
- **optional** `key`: Fragments declared with the explicit `<Fragment>` syntax may have [keys.](/learn/rendering-lists#keeping-list-items-in-order-with-key)
30+
- **valinnainen** `key`: Fragmentit jotka on määritelty `<Fragment>` syntaksilla voivat sisältää [avaimia.](/learn/rendering-lists#keeping-list-items-in-order-with-key)
3131

3232
#### Rajoitukset {/*caveats*/}
3333

34-
- If you want to pass `key` to a Fragment, you can't use the `<>...</>` syntax. You have to explicitly import `Fragment` from `'react'` and render `<Fragment key={yourKey}>...</Fragment>`.
34+
- Jos haluat välittää `key`:n Fragmentille, et voi käyttää `<></>` syntaksia. Sinun täytyy tuoda `Fragment` `'react'`-kirjastosta ja renderöidä `<Fragment key={yourKey}>...</Fragment>`.
3535

36-
- React does not [reset state](/learn/preserving-and-resetting-state) when you go from rendering `<><Child /></>` to `[<Child />]` or back, or when you go from rendering `<><Child /></>` to `<Child />` and back. This only works a single level deep: for example, going from `<><><Child /></></>` to `<Child />` resets the state. See the precise semantics [here.](https://gist.github.com/clemmy/b3ef00f9507909429d8aa0d3ee4f986b)
36+
- React ei [nollaa tilaa](/learn/preserving-and-resetting-state) kun siirryt renderöimästä `<><Child /></>`:n `[<Child />]`:iin tai takaisin, tai kun siirryt renderöimästä `<><Child /></>`:n `<Child />`:iin ja takaisin. Tämä toimii vain yhden tason syvyyteen asti: esimerkiksi siirtyminen `<><><Child /></></>` `<Child />` nollaa tilan. Katso tarkat semantiikat [täältä.](https://gist.github.com/clemmy/b3ef00f9507909429d8aa0d3ee4f986b)
3737

3838
---
3939

4040
## Käyttö {/*usage*/}
4141

42-
### Returning multiple elements {/*returning-multiple-elements*/}
42+
### Useiden elementtien palauttaminen {/*returning-multiple-elements*/}
4343

44-
Use `Fragment`, or the equivalent `<>...</>` syntax, to group multiple elements together. You can use it to put multiple elements in any place where a single element can go. For example, a component can only return one element, but by using a Fragment you can group multiple elements together and then return them as a group:
44+
Käytä `Fragment`:ia, tai sitä vastaavaa `<></>` syntaksia, ryhmitelläksesi useita elementtejä yhteen. Voit käyttää sitä laittamaan useita elementtejä mihin tahansa paikkaan, johon yksi elementti voi mennä. Esimerkiksi komponentti voi palauttaa vain yhden elementin, mutta käyttämällä Fragmenttia voit ryhmitellä useita elementtejä yhteen ja palauttaa ne ryhmänä:
4545

4646
```js {3,6}
4747
function Post() {
@@ -54,16 +54,16 @@ function Post() {
5454
}
5555
```
5656

57-
Fragments are useful because grouping elements with a Fragment has no effect on layout or styles, unlike if you wrapped the elements in another container like a DOM element. If you inspect this example with the browser tools, you'll see that all `<h1>` and `<article>` DOM nodes appear as siblings without wrappers around them:
57+
Fragmentit ovat hyödyllisiä koska elementtien ryhmittely Fragmentin sisään ei vaikuta layouttiin tai tyyleihin, toisin kuin jos käärisit elementit toiseen DOM-elementtiin. Jos tarkastelet tätä esimerkkiä selaimen työkaluilla, näet että kaikki `<h1>` ja `<article>` DOM-nodet näkyvät sisaruksina ilman wrapper-elementtejä niiden ympärillä:
5858

5959
<Sandpack>
6060

6161
```js
6262
export default function Blog() {
6363
return (
6464
<>
65-
<Post title="An update" body="It's been a while since I posted..." />
66-
<Post title="My new blog" body="I am starting a new blog!" />
65+
<Post title="Päivitys" body="Siitä on hetki kun viimeksi julkaisin..." />
66+
<Post title="Uusi blogini" body="Aloitan uuden blogin!" />
6767
</>
6868
)
6969
}
@@ -94,9 +94,9 @@ function PostBody({ body }) {
9494

9595
<DeepDive>
9696

97-
#### How to write a Fragment without the special syntax? {/*how-to-write-a-fragment-without-the-special-syntax*/}
97+
#### Miten kirjoittaa Fragment ilman erityissyntaksia? {/*how-to-write-a-fragment-without-the-special-syntax*/}
9898

99-
The example above is equivalent to importing `Fragment` from React:
99+
Tämä esimerkki vastaa `Fragment`:in tuomista Reactista:
100100

101101
```js {1,5,8}
102102
import { Fragment } from 'react';
@@ -111,15 +111,14 @@ function Post() {
111111
}
112112
```
113113

114-
Usually you won't need this unless you need to [pass a `key` to your `Fragment`.](#rendering-a-list-of-fragments)
114+
Useimmiten et tule tarvitsemaan tätä ellei sinun tarvitse [välittää `key` Fragmentille.](#rendering-a-list-of-fragments)
115115

116116
</DeepDive>
117117

118118
---
119+
### Useiden elementtien määrittäminen muuttujaan {/*assigning-multiple-elements-to-a-variable*/}
119120

120-
### Assigning multiple elements to a variable {/*assigning-multiple-elements-to-a-variable*/}
121-
122-
Like any other element, you can assign Fragment elements to variables, pass them as props, and so on:
121+
Kuten mitä tahansa muita elementtejä, voit määrittää Fragmentin elementtejä muuttujiin, välittää niitä propseina, jne:
123122

124123
```js
125124
function CloseDialog() {
@@ -131,25 +130,24 @@ function CloseDialog() {
131130
);
132131
return (
133132
<AlertDialog buttons={buttons}>
134-
Are you sure you want to leave this page?
133+
Oletko varma, että haluat poistua tältä sivulta?
135134
</AlertDialog>
136135
);
137136
}
138137
```
139138
140139
---
140+
### Tekstin ryhmittäminen elementteihin {/*grouping-elements-with-text*/}
141141
142-
### Grouping elements with text {/*grouping-elements-with-text*/}
143-
144-
You can use `Fragment` to group text together with components:
142+
Voit käyttää `Fragment`:ia ryhmitelläksesi tekstin yhteen komponenttien kanssa:
145143
146144
```js
147145
function DateRangePicker({ start, end }) {
148146
return (
149147
<>
150-
From
148+
Aloituspäivä:
151149
<DatePicker date={start} />
152-
to
150+
Lopetuspäivä:
153151
<DatePicker date={end} />
154152
</>
155153
);
@@ -158,9 +156,9 @@ function DateRangePicker({ start, end }) {
158156
159157
---
160158
161-
### Rendering a list of Fragments {/*rendering-a-list-of-fragments*/}
159+
### Fragment-listan renderöiminen {/*rendering-a-list-of-fragments*/}
162160
163-
Here's a situation where you need to write `Fragment` explicitly instead of using the `<></>` syntax. When you [render multiple elements in a loop](/learn/rendering-lists), you need to assign a `key` to each element. If the elements within the loop are Fragments, you need to use the normal JSX element syntax in order to provide the `key` attribute:
161+
Tässä on tilanne, jossa sinun täytyy kirjoittaa `Fragment` eksplisiittisesti sen sijaan, että käyttäisit `<></>` syntaksia. Kun [renderöit useita elementtejä silmukassa](/learn/rendering-lists), sinun täytyy määrittää `key` jokaiselle elementille. Jos elementit silmukan sisällä ovat Fragmentteja, sinun täytyy käyttää normaalia JSX-elementti -syntaksia, jotta voit välittää `key` attribuutin:
164162
165163
```js {3,6}
166164
function Blog() {
@@ -173,16 +171,16 @@ function Blog() {
173171
}
174172
```
175173
176-
You can inspect the DOM to verify that there are no wrapper elements around the Fragment children:
174+
Voit tarkastella DOM:ia varmistaaksesi, että Fragmentin lapsilla ei ole wrapper-elementtejä:
177175
178176
<Sandpack>
179177
180178
```js
181179
import { Fragment } from 'react';
182180

183181
const posts = [
184-
{ id: 1, title: 'An update', body: "It's been a while since I posted..." },
185-
{ id: 2, title: 'My new blog', body: 'I am starting a new blog!' }
182+
{ id: 1, title: 'Päivitys', body: "Siitä on hetki kun viimeksi julkaisin..." },
183+
{ id: 2, title: 'Uusi blogini', body: 'Aloitan uuden blogin!' }
186184
];
187185

188186
export default function Blog() {

0 commit comments

Comments
 (0)