-
Notifications
You must be signed in to change notification settings - Fork 52
docs/rendering-elements.md #8
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
565b127
Update examples and rendering elements page
ph1p ea9bbdc
Update text and add german gif
ph1p e901cf8
Change Notiz to Hinweis
ph1p 1073690
Update content/docs/rendering-elements.md
ChrisB9 55bbd44
Update content/docs/rendering-elements.md
ChrisB9 5ea1c23
Update examples/rendering-elements/render-an-element.js
ChrisB9 fd2fd4e
Update texts
ph1p a4246a8
Update text
ph1p File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,82 @@ | ||
--- | ||
id: rendering-elements | ||
title: Rendering Elements | ||
title: Darstellungselemente | ||
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. | ||
Elemente sind die kleinsten Bestandteile von React-Apps. | ||
|
||
An element describes what you want to see on the screen: | ||
Ein Element beschreibt was du auf dem Bildschirm sehen möchtest: | ||
|
||
```js | ||
const element = <h1>Hello, world</h1>; | ||
const element = <h1>Hallo Welt</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. | ||
Anders als die DOM Elemente eines Browsers, sind React Elemente schlichte kosteneffektive Objekte. | ||
React DOM kümmert sich um das Aktualisieren des DOMs und den dazugehörigen React Elementen. | ||
|
||
>**Note:** | ||
>**Hinweis:** | ||
> | ||
>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. | ||
>Man könnte Elemente mit dem allgemein bekannterem Konzept der "Komponenten" verwechseln. Komponenten werden wir | ||
>im [nächsten Abschnitt](/docs/components-and-props.html) behandeln. | ||
>Elemente sind das, woraus Komponenten "gemacht" werden und wir empfehlen dir erst diesen Abschnitt zu lesen, bevor du weiter machst. | ||
|
||
## Rendering an Element into the DOM {#rendering-an-element-into-the-dom} | ||
## Ein Element in das DOM rendern {#rendering-an-element-into-the-dom} | ||
|
||
Let's say there is a `<div>` somewhere in your HTML file: | ||
Nehmen wir mal an, wir haben ein `<div>` Element irgendwo in einer HTML-Datei: | ||
|
||
```html | ||
<div id="root"></div> | ||
``` | ||
|
||
We call this a "root" DOM node because everything inside it will be managed by React DOM. | ||
Dieses Element nennen wir "root" DOM Knoten. Alles innerhalb dieses Elements wird von React DOM verwaltet. | ||
|
||
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. | ||
Anwendungen, die mit React gebaut worden, haben normalerweise nur einen root DOM Knoten. Wenn du React in eine bestehende Anwendung einfügst, kannst du aber soviele DOM Knoten haben, wie du möchtest. | ||
|
||
To render a React element into a root DOM node, pass both to `ReactDOM.render()`: | ||
Um ein Element in den root DOM Knoten zu rendern, muss du nur beides an `ReactDOM.render()` übergeben: | ||
|
||
`embed:rendering-elements/render-an-element.js` | ||
|
||
[](codepen://rendering-elements/render-an-element) | ||
[Auf CodePen ausprobieren](codepen://rendering-elements/render-an-element) | ||
|
||
It displays "Hello, world" on the page. | ||
Es wird "Hallo Welt" auf der Seite angezeigt. | ||
|
||
## Updating the Rendered Element {#updating-the-rendered-element} | ||
## Aktualisieren des gerenderten Elements {#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. | ||
React Elemente sind [immuntable](https://en.wikipedia.org/wiki/Immutable_object) (unveränderbar). Wenn du einmal ein Element erstellt hast, kannst du dessen | ||
Kind-Elemente oder Attribute nicht mehr verändern. Eine Element kannst du dir vorstellen, wie ein einzelnes Bild eines Filmes: Es repräsentiert die Benutzeroberfläche (UI) zu einem bestimmten Zeitpunkt. | ||
|
||
With our knowledge so far, the only way to update the UI is to create a new element, and pass it to `ReactDOM.render()`. | ||
Mit dem was wir bis jetzt erfahren haben, wissen wir nur, dass der einzige Weg um die Benutzeroberfläche zu Aktualisieren und neue Elemente zu erstellen, das Aufrufen von `ReactDOM.render()` ist. | ||
|
||
Consider this ticking clock example: | ||
Wir nehmen uns einmal dieses Beispiel einer tickenden Uhr: | ||
|
||
`embed:rendering-elements/update-rendered-element.js` | ||
|
||
[](codepen://rendering-elements/update-rendered-element) | ||
[Auf CodePen ausprobieren](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. | ||
Jede Sekunden wird `ReactDOM.render()` mit Hilfe einer Callback-Funktion von [`setInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval) aufgerufen. | ||
|
||
>**Note:** | ||
>**Hinweis:** | ||
> | ||
>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). | ||
>In der Praxis rufen die meisten React Anwendungen `ReactDOM.render()` nur einmal auf. Im nächsten Abschnitt lernen wir, wie solch ein Code in einzelne [Zustandskomponenten](/docs/state-and-lifecycle.html) gekapselt wird. | ||
> | ||
>We recommend that you don't skip topics because they build on each other. | ||
>Wir empfehlen dir, Abschnitte nicht zu überspringen, da sie aufeinander aufbauen. | ||
|
||
## React Only Updates What's Necessary {#react-only-updates-whats-necessary} | ||
## React aktualisiert nur das Nötigste {#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 vergleicht das vorherige und jetztige Element und dessen Kindelemente miteinander. | ||
Um das DOM in den gwünschten Zustand zu bringen, werden nur die Elemente im DOM aktualisiert, die wirklich eine Änderung beinhalten. | ||
|
||
You can verify by inspecting the [last example](codepen://rendering-elements/update-rendered-element) with the browser tools: | ||
Du kannst es nachprüfen, indem du das [letzte Beispiel](codepen://rendering-elements/update-rendered-element) mit den Browser Tools aufrufst: | ||
|
||
 | ||
 | ||
|
||
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. | ||
Obwohl wir jede Sekunde ein Element erstellen, das den kompletten UI Baum aktualisiert, | ||
wird nur der Text-Inhalt durch React DOM aktualisiert, dessen Inhalt sich wirklich geändert hat. | ||
|
||
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. | ||
Nach unserer Erfahrung macht es mehr Sinn darüber nachzudenken, wie die Benutzeroberfläche zu einem bestimmten Zeitpunkt aussieht, anstatt | ||
sich darüber Gedanken zu machen, wie sie sich im Laufe der Zeit verändert. Dieses Denken verhindert eine ganze Reihe von Fehlern. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
const element = <h1>Hello, world</h1>; | ||
const element = <h1>Hallo Welt</h1>; | ||
ReactDOM.render(element, document.getElementById('root')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.