Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate Rendering Elements page #42

Merged
merged 21 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
30f50e3
Translate `Rendering Elements` page
arekmaz Mar 5, 2019
bef6b42
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
caecd53
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
84b81c6
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
75c49c3
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
841de88
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
d35b1d7
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
a296108
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
9a1d9e5
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
47cd022
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
2f17ae1
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
2101bc5
Update content/docs/rendering-elements.md
jakubdrozdek Mar 6, 2019
353a1c2
Translate examples/rendering-elements/update-rendered-element.js file
arekmaz Mar 6, 2019
679cacb
Translate examples/rendering-elements/render-an-element.js file
arekmaz Mar 6, 2019
ff7e7d8
Add fixes to `Rendering elements` page translation
arekmaz Mar 6, 2019
6cf98a9
Update content/docs/rendering-elements.md
arekmaz Mar 6, 2019
90b0926
Update content/docs/rendering-elements.md
g12i Mar 6, 2019
03b521e
Update content/docs/rendering-elements.md
g12i Mar 6, 2019
aee0fb3
Update content/docs/rendering-elements.md
g12i Mar 6, 2019
57f8f92
Add a small translation patch
arekmaz Mar 6, 2019
1ed6105
Merge branch 'translate-rendering-elements' of github.com:arekmaz/pl.…
arekmaz Mar 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions content/docs/rendering-elements.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,76 @@
---
id: rendering-elements
title: Rendering Elements
title: Renderowanie elementów
permalink: docs/rendering-elements.html
redirect_from:
- "docs/displaying-data.html"
prev: introducing-jsx.html
next: components-and-props.html
---

Elements are the smallest building blocks of React apps.
Elementy to najmniejsze bloki budujące reactowe aplikacje.

An element describes what you want to see on the screen:
Element opisuje, co chcesz zobaczyć na ekranie:

```js
const element = <h1>Hello, world</h1>;
const element = <h1>Witaj, świecie!</h1>;
```

Unlike browser DOM elements, React elements are plain objects, and are cheap to create. React DOM takes care of updating the DOM to match the React elements.
W przeciwieństwie do elementów drzewa DOM w przeglądarce, reactowe elementy są zwykłymi obiektami i mają niski koszt tworzenia. React DOM zajmuje się aktualizowaniem drzewa DOM tak, aby odpowiadało strukturze elementów reactowych.

>**Note:**

>**Wskazówka:**
>
>One might confuse elements with a more widely known concept of "components". We will introduce components in the [next section](/docs/components-and-props.html). Elements are what components are "made of", and we encourage you to read this section before jumping ahead.
>Łatwo pomylić elementy z szerzej znaną koncepcją "komponentów". Komponenty przedstawimy w [kolejnym rozdziale](/docs/components-and-props.html). Elementy są tym, z czego komponenty "są zbudowane". Zachęcamy do przeczytania tego rozdziału przed przejściem dalej.

## Rendering an Element into the DOM {#rendering-an-element-into-the-dom}
## Renderowanie elementu w drzewie DOM {#rendering-an-element-into-the-dom}

Let's say there is a `<div>` somewhere in your HTML file:
Powiedzmy, że gdzieś w twoim pliku HTML jest `<div>`:

```html
<div id="root"></div>
```

We call this a "root" DOM node because everything inside it will be managed by React DOM.
Ten węzeł drzewa DOM nazywamy "korzeniem", bo wszystko, co się w nim znajduje będzie zarządzane przez React DOM.

Applications built with just React usually have a single root DOM node. If you are integrating React into an existing app, you may have as many isolated root DOM nodes as you like.
Aplikacje zbudowane przy pomocy samego Reacta zazwyczaj posiadają pojedynczy węzeł drzewa DOM. Jeśli natomiast integrujesz reactową aplikację z już istniejącą aplikacją, możesz mieć tyle odizolowanych "korzeni", ile chcesz.

To render a React element into a root DOM node, pass both to `ReactDOM.render()`:
Aby wyrenderować reactowy element w węźle drzewa DOM, przekaż oba do `ReactDOM.render()`:

`embed:rendering-elements/render-an-element.js`

[](codepen://rendering-elements/render-an-element)

It displays "Hello, world" on the page.
Na stronie wyświetli się napis "Witaj, świecie!".

## Updating the Rendered Element {#updating-the-rendered-element}
## Aktualizowanie wyrenderowanego elementu {#updating-the-rendered-element}

React elements are [immutable](https://en.wikipedia.org/wiki/Immutable_object). Once you create an element, you can't change its children or attributes. An element is like a single frame in a movie: it represents the UI at a certain point in time.
Reactowe elementy są [niezmienne](https://en.wikipedia.org/wiki/Immutable_object) (ang. *immutable*). Kiedy już stworzysz element, nie możesz zmienić jego komponentów potomnych ani właściwości. Element jest jak pojedyncza klatka z filmu: reprezentuje interfejs użytkownika w pewnym punkcie czasu.

With our knowledge so far, the only way to update the UI is to create a new element, and pass it to `ReactDOM.render()`.
Przy naszej dotychczasowej wiedzy, jedynym sposobem aktualizacji interfejsu użytkownika jest stworzenie nowego elementu i przekazanie go do `ReactDOM.render()`.

Consider this ticking clock example:
Rozważ ten przykład tykającego zegara:

`embed:rendering-elements/update-rendered-element.js`

[](codepen://rendering-elements/update-rendered-element)

It calls `ReactDOM.render()` every second from a [`setInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval) callback.
Wywołuje on `ReactDOM.render()` z wewnątrz funkcji zwrotnej [`setInterval()`](https://developer.mozilla.org/pl/docs/Web/API/Window/setInterval) co sekundę.

>**Note:**
>**Wskazówka:**
>
>In practice, most React apps only call `ReactDOM.render()` once. In the next sections we will learn how such code gets encapsulated into [stateful components](/docs/state-and-lifecycle.html).
>W praktyce większość reactowych aplikacji wywołuje `ReactDOM.render()` tylko raz. W kolejnych rozdziałach dowiemy się, jak można taki kod wyizolować do [komponentów stanowych](/docs/state-and-lifecycle.html).
>
>We recommend that you don't skip topics because they build on each other.
>Radzimy jednak nie pomijać żadnych tematów, ponieważ kolejne rozdziały oparte są o wiedzę z poprzednich.

## React Only Updates What's Necessary {#react-only-updates-whats-necessary}
## React uaktualnia tylko to, co potrzebne {#react-only-updates-whats-necessary}

React DOM compares the element and its children to the previous one, and only applies the DOM updates necessary to bring the DOM to the desired state.
React DOM porównuje element i jego potomków do poprzedniego oraz nakłada tylko te aktualizacje drzewa DOM, które konieczne są do doprowadzenia go do pożądanego stanu.

You can verify by inspecting the [last example](codepen://rendering-elements/update-rendered-element) with the browser tools:
Możesz to sprawdzić przez zbadanie (ang. *inspect*) [ostatniego przykładu](codepen://rendering-elements/update-rendered-element) przy użyciu narzędzi deweloperskich:

![DOM inspector showing granular updates](../images/docs/granular-dom-updates.gif)
![inspektor DOM pokazujący cząstkowe aktualizacje](../images/docs/granular-dom-updates.gif)

Even though we create an element describing the whole UI tree on every tick, only the text node whose contents has changed gets updated by React DOM.
Mimo że przy każdym tyknięciu zegara tworzymy element opisujący cały interfejs użytkownika, tylko węzeł tekstowy, którego treść uległa zmianie, zostaje zaktualizowany przez React DOM.

In our experience, thinking about how the UI should look at any given moment rather than how to change it over time eliminates a whole class of bugs.
Według naszego doświadczenia, myślenie o tym, jak powinien wyglądać interfejs użytkownika w danym momencie, a nie jak zmieniać go w czasie, eliminuje całą klasę błędów.
2 changes: 1 addition & 1 deletion examples/rendering-elements/render-an-element.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const element = <h1>Hello, world</h1>;
const element = <h1>Witaj, świecie!</h1>;
ReactDOM.render(element, document.getElementById('root'));
4 changes: 2 additions & 2 deletions examples/rendering-elements/update-rendered-element.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function tick() {
const element = (
<div>
<h1>Hello, world!</h1>
<h2>It is {new Date().toLocaleTimeString()}.</h2>
<h1>Witaj świecie!</h1>
<h2>Aktualny czas: {new Date().toLocaleTimeString()}.</h2>
</div>
);
// highlight-next-line
Expand Down