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
Translated API-Referenz/ReactDOM #45
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,53 +6,52 @@ category: Reference | |||||
permalink: docs/react-dom.html | ||||||
--- | ||||||
|
||||||
If you load React from a `<script>` tag, these top-level APIs are available on the `ReactDOM` global. If you use ES6 with npm, you can write `import ReactDOM from 'react-dom'`. If you use ES5 with npm, you can write `var ReactDOM = require('react-dom')`. | ||||||
Falls du React von einem `<script>`-Tag heraus lädst, sind diese Top-Level APIs im globalen `ReactDOM`-Objekt verfügbar. Solltest du ES6 mit npm verwenden, kannst du `import ReactDOM from 'react-dom'` schreiben. Wenn du ES5 mit npm verwendest, kannst du `var React = require('react-dom')` schreiben. | ||||||
|
||||||
## Overview {#overview} | ||||||
## Übersicht {#overview} | ||||||
|
||||||
The `react-dom` package provides DOM-specific methods that can be used at the top level of your app and as an escape hatch to get outside of the React model if you need to. Most of your components should not need to use this module. | ||||||
Das `react-dom` Paket stellt DOM-spezifische Methoden zur Verfügung, die bei Bedarf am Einstiegspunkt deiner Applikation und als Notausstieg, um aus dem React Model auszubrechen, genutzt werden können. Die meisten deiner Komponenten sollten nicht auf dieses Modul angewiesen sein. | ||||||
|
||||||
- [`render()`](#render) | ||||||
- [`hydrate()`](#hydrate) | ||||||
- [`unmountComponentAtNode()`](#unmountcomponentatnode) | ||||||
- [`findDOMNode()`](#finddomnode) | ||||||
- [`createPortal()`](#createportal) | ||||||
|
||||||
### Browser Support {#browser-support} | ||||||
### Browser Unterstützung {#browser-support} | ||||||
|
||||||
React supports all popular browsers, including Internet Explorer 9 and above, although [some polyfills are required](/docs/javascript-environment-requirements.html) for older browsers such as IE 9 and IE 10. | ||||||
React unterstützt alle populären Browser, einschließlich Internet Explorer 9 und höher, auch wenn für ältere Browser, wie IE9 und IE10, [einige Polyfills notwendig](/docs/javascript-environment-requirements.html) sind. | ||||||
|
||||||
> Note | ||||||
> Hinweis | ||||||
> | ||||||
> We don't support older browsers that don't support ES5 methods, but you may find that your apps do work in older browsers if polyfills such as [es5-shim and es5-sham](https://github.com/es-shims/es5-shim) are included in the page. You're on your own if you choose to take this path. | ||||||
> Wir unterstützen keine älteren Browser, die keine ES5 Methoden unterstützen. Möglicherweiße funktionieren deine Applikationen auch in älteren Browser, wenn Polyfills wie z.B. [es5-shim und es5-sham](https://github.com/es-shims/es5-shim) auf deiner Seite eingebunden sind. Du bist auf dich alleine gestellt, wenn du diesen Weg einschlägst. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion:
|
||||||
|
||||||
* * * | ||||||
|
||||||
## Reference {#reference} | ||||||
## Referenz {#reference} | ||||||
|
||||||
### `render()` {#render} | ||||||
|
||||||
```javascript | ||||||
ReactDOM.render(element, container[, callback]) | ||||||
``` | ||||||
|
||||||
Render a React element into the DOM in the supplied `container` and return a [reference](/docs/more-about-refs.html) to the component (or returns `null` for [stateless components](/docs/components-and-props.html#functional-and-class-components)). | ||||||
Render ein React Element in das DOM in dem zur Verfügung gestellten `container` und gib eine [Referenz](/docs/more-about-refs.html) zur Komponente zurück (oder `null` für [Funktionale Komponenten](/docs/components-and-props.html#functional-and-class-components)). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
If the React element was previously rendered into `container`, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React element. | ||||||
Wenn das React Element zuvor bereits in einem `container` gerendert wurde, führt diese Operation ein Update aus und ändert nur das DOM so wie es notwendig ist, um das aktuellste React Element darzustellen. | ||||||
|
||||||
If the optional callback is provided, it will be executed after the component is rendered or updated. | ||||||
Wird ein optionaler Callback zur Verfügung gestellt, wird dieser ausgeführt nachdem die Komponente gerendert oder geupdated wurde. | ||||||
|
||||||
> Note: | ||||||
> Hinweis: | ||||||
> | ||||||
> `ReactDOM.render()` controls the contents of the container node you pass in. Any existing DOM elements inside are replaced when first called. Later calls use React’s DOM diffing algorithm for efficient updates. | ||||||
> `ReactDOM.render()` kontrolliert den Inhalt des Container Knoten den du übergeben hast. Jedes darin existierende DOM Element wird beim ersten Aufruf ersetzt. Spätere Aufrufe nutzen Reacts DOM diffing Algorithmus für effiziente Updates. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
> | ||||||
> `ReactDOM.render()` does not modify the container node (only modifies the children of the container). It may be possible to insert a component to an existing DOM node without overwriting the existing children. | ||||||
> `ReactDOM.render()` verändert nicht den Container Knoten (es werden nur die untergeordneten Container Elemente modifiziert). Es kann möglich sein eine Komponente in einen existierenden DOM Knoten einzufügen ohne die bereits existierenden untergeordneten Elemente zu überschreiben. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
> | ||||||
> `ReactDOM.render()` currently returns a reference to the root `ReactComponent` instance. However, using this return value is legacy | ||||||
> and should be avoided because future versions of React may render components asynchronously in some cases. If you need a reference to the root `ReactComponent` instance, the preferred solution is to attach a | ||||||
> [callback ref](/docs/more-about-refs.html#the-ref-callback-attribute) to the root element. | ||||||
> `ReactDOM.render()` gibt aktuell eine Referenz zur Wurzel `ReactComponent` Instanz zurück. Nichtsdestotrotz ist der Gebrauch dieses Rückgabewerts historisch bedingt und sollte vermieden werden, da in zukünftigen Versionen von React das Rendern von Komponenten in einigen Fällen asynchron erfolgen kann. Solltest du eine Referenz zur Instanz der Wurzel `ReactComponent` benötigen, sieht die bevorzugte Lösung vor, ein [callback ref](/docs/more-about-refs.html#the-ref-callback-attribute) des Wurzel-Elements hinzuzufügen. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
> | ||||||
> Using `ReactDOM.render()` to hydrate a server-rendered container is deprecated and will be removed in React 17. Use [`hydrate()`](#hydrate) instead. | ||||||
> Die Nutzung von `ReactDOM.render()` um eine auf dem Server gerenderte Komponente zu hydrieren ist veraltet und wird in React 17 entfernt. Nutze stattdessen [`hydrate()`](#hydrate). | ||||||
|
||||||
* * * | ||||||
|
||||||
|
@@ -62,15 +61,16 @@ If the optional callback is provided, it will be executed after the component is | |||||
ReactDOM.hydrate(element, container[, callback]) | ||||||
``` | ||||||
|
||||||
Same as [`render()`](#render), but is used to hydrate a container whose HTML contents were rendered by [`ReactDOMServer`](/docs/react-dom-server.html). React will attempt to attach event listeners to the existing markup. | ||||||
Genauso wie [`render()`](#render), aber es wird genutzt um einen Container, dessen HTML Inhalt durch [`ReactDOMServer`](/docs/react-dom-server.html) gerendert wurde, zu hydrieren. React wird versuchen Event Listener dem existierendem Markup hinzuzufügen. | ||||||
|
||||||
React expects that the rendered content is identical between the server and the client. It can patch up differences in text content, but you should treat mismatches as bugs and fix them. In development mode, React warns about mismatches during hydration. There are no guarantees that attribute differences will be patched up in case of mismatches. This is important for performance reasons because in most apps, mismatches are rare, and so validating all markup would be prohibitively expensive. | ||||||
React erwartet, dass der gerenderte Inhalt identisch zwischen Server und Client ist. Unterschiede im textlichen Inhalt werden zwar behoben, sollten aber als Fehler betrachtet und repariert werden. Im Entwicklungsmodus warnt React bei Nichtübereinstimmung während der Hydration. Es wird keine Garantie gegeben, dass Unterschiede bei Attributen behoben werden, wenn diese nicht übereinstimmen. Dies ist aus Leistungsgründen für die meisten Applikationen wichtig, da Nichtübereinstimmungen selten sind und dem gegenüber ihre Überprüfung unverhältnismäßig aufwendig wäre. | ||||||
|
||||||
If a single element's attribute or text content is unavoidably different between the server and the client (for example, a timestamp), you may silence the warning by adding `suppressHydrationWarning={true}` to the element. It only works one level deep, and is intended to be an escape hatch. Don't overuse it. Unless it's text content, React still won't attempt to patch it up, so it may remain inconsistent until future updates. | ||||||
Wenn das Attribut eines einzelnen Elements oder der Textinhalt zwischen Server und Client unvermeidbar unterschiedlich ist (z.B. bei einem Timestamp), kannst du die Warnungen durch das Hinzufügen von `suppressHydrationWarning={true}` am Element unterdrücken. Dies funktioniert aber nur eine Ebene tief und ist als Notlösung vorgesehen. Überstrapaziere die Nutzung daher nicht. Sollte es kein Textinhalt sein, wird React weiterhin nicht versuchen, die Unterschiede zu beheben, daher kann das Verhalten bis zu zukünftigen Updates inkonsistenz bleiben. | ||||||
|
||||||
If you intentionally need to render something different on the server and the client, you can do a two-pass rendering. Components that render something different on the client can read a state variable like `this.state.isClient`, which you can set to `true` in `componentDidMount()`. This way the initial render pass will render the same content as the server, avoiding mismatches, but an additional pass will happen synchronously right after hydration. Note that this approach will make your components slower because they have to render twice, so use it with caution. | ||||||
Versuchst du absichtlich etwas anderes auf dem Server als auf dem Client zu rendern, kannst du ein Rendern mit zwei Durchgängen durchführen. Eine Komponente, die etwas anderes auf dem Client rendert kann eine State Variable wie `this.state.isClient` auslesen, welche von dir in `componentDidMount()` auf `true` gesetzt wird. Dadurch wird beim ersten Render Durchgang dasselbe wie auf dem Server gerendert und Nichtübereinstimmungen vermieden, aber ein zusätzlicher Client Render Durchgang geschieht synchron direkt nach der Hydration. | ||||||
Vergesse nicht, dass dieses Vorgehen deine Komponenten verlangsamt, da dass rendern zweimal geschieht. Nutze es daher mit Vorsicht. | ||||||
|
||||||
Remember to be mindful of user experience on slow connections. The JavaScript code may load significantly later than the initial HTML render, so if you render something different in the client-only pass, the transition can be jarring. However, if executed well, it may be beneficial to render a "shell" of the application on the server, and only show some of the extra widgets on the client. To learn how to do this without getting the markup mismatch issues, refer to the explanation in the previous paragraph. | ||||||
Vergesse nicht das Benutzererlebnis bei langsamen Verbindungen zu berücksichtigen. Der JavaScript Code kann deutlich später geladen werden als das erste initiale rendern des HTML. Renderst du daher etwas anderes beim Client Render Durchgang kann der Übergang ruckhaft sein. Wird dieses Vorgehen aber gut ausgeführt, kann es von Vorteil sein eine Applikationshülle auf dem Server zu rendern und nur zusätzliche Widgets erst auf dem Client anzuzeigen. Um zu erfahren, wie dies getan werden kann und dabei das Problem der Nichtübereinstimmung von Markup zu umgehen, schaue dir den vorherigen Paragraph an. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
* * * | ||||||
|
||||||
|
@@ -80,28 +80,29 @@ Remember to be mindful of user experience on slow connections. The JavaScript co | |||||
ReactDOM.unmountComponentAtNode(container) | ||||||
``` | ||||||
|
||||||
Remove a mounted React component from the DOM and clean up its event handlers and state. If no component was mounted in the container, calling this function does nothing. Returns `true` if a component was unmounted and `false` if there was no component to unmount. | ||||||
Entfernt eine React Komponente die gemounted wurde von dem DOM und entfernt ihren State, sowie Event Handler. Wenn keine Komponente im Container gemounted ist, tut der Aufruf dieser Funktion nichts. Gibt `true` zurück, wenn eine Komponente erfolgreich unmounted wurde, andernfalls `false`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
* * * | ||||||
|
||||||
### `findDOMNode()` {#finddomnode} | ||||||
|
||||||
> Note: | ||||||
> Hinweis: | ||||||
> | ||||||
> `findDOMNode` is an escape hatch used to access the underlying DOM node. In most cases, use of this escape hatch is discouraged because it pierces the component abstraction. [It has been deprecated in `StrictMode`.](/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage) | ||||||
> `findDOMNode` ist eine Notlösung die genutzt wird um auf den zugrunde liegenden DOM Knoten zuzugreifen. In den meisten Fällen wird von der Nutzung dieser Notlösung abgeraten, da es die Abstraktion durch Komponenten löchrig macht. [Die Nutzung ist im `StrictMode` veraltet.](/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```javascript | ||||||
ReactDOM.findDOMNode(component) | ||||||
``` | ||||||
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements. **In most cases, you can attach a ref to the DOM node and avoid using `findDOMNode` at all.** | ||||||
|
||||||
When a component renders to `null` or `false`, `findDOMNode` returns `null`. When a component renders to a string, `findDOMNode` returns a text DOM node containing that value. As of React 16, a component may return a fragment with multiple children, in which case `findDOMNode` will return the DOM node corresponding to the first non-empty child. | ||||||
Ist die übergebene Komponente im DOM gemounted, gibt sie das passende native Browser DOM Element zurück. Die Methode ist nützlich um Werte aus Formfelder im DOM auszulesen oder Messungen im DOM auszuführen. **In den meisten Fällen kannst du eine Ref an den DOM Knoten anhängen und die Nutzung von `findDOMNode` komplett vermeiden.** | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Wenn eine Komponente `null` oder `false` rendert, gibt `findDOMNode` `null` zurück. Wenn eine Komponente einen String rendert, gibt `findDOMNode` einen DOM Text-Knoten zurück, welche diesen Text enthält. Mit React 16 kann eine Komponente ein Fragment zurückgeben, dass mehrere untergeordnete Komponenten enthält. In diesem Fall gibt `findDOMNode` den DOM Knoten zurück, der dem ersten nicht leeren untergeordneten Element entspricht. | ||||||
|
||||||
> Note: | ||||||
> Hinweis: | ||||||
> | ||||||
> `findDOMNode` only works on mounted components (that is, components that have been placed in the DOM). If you try to call this on a component that has not been mounted yet (like calling `findDOMNode()` in `render()` on a component that has yet to be created) an exception will be thrown. | ||||||
> `findDOMNode` funktioniert nur bei gemounteten Komponenten (also Komponenten die in das DOM platziert wurden). Versuchst du einen Aufruf bei einer Komponente die noch nicht gemounted wurde (z.B. beim Aufruf von `findDOMNode()` in `render()` innerhalb einer Komponente die noch nicht erstellt wurde) wird eine Ausnahme geworfen. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
> | ||||||
> `findDOMNode` cannot be used on function components. | ||||||
> `findDOMNode` kann nicht bei Funktionskomponenten genutzt werden. | ||||||
|
||||||
* * * | ||||||
|
||||||
|
@@ -111,4 +112,4 @@ When a component renders to `null` or `false`, `findDOMNode` returns `null`. Whe | |||||
ReactDOM.createPortal(child, container) | ||||||
``` | ||||||
|
||||||
Creates a portal. Portals provide a way to [render children into a DOM node that exists outside the hierarchy of the DOM component](/docs/portals.html). | ||||||
Erstellt ein Portal. Portale sind ein Weg um [untergeordnete Elemente in einen DOM Knoten zu rendern die außerhalb der Hierarchie der DOM Komponente existieren](docs/portals.html). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.