Skip to content
This repository was archived by the owner on Apr 21, 2023. It is now read-only.

Commit e1c9f3c

Browse files
authored
Merge pull request #80 from nglvnyls/traduccio_-API-ReactDom
Traduccio REFERENCIA API- ReactDom
2 parents 859903f + 19421dd commit e1c9f3c

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

Diff for: content/docs/reference-react-dom.md

+36-36
Original file line numberDiff line numberDiff line change
@@ -6,109 +6,109 @@ category: Reference
66
permalink: docs/react-dom.html
77
---
88

9-
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')`.
9+
Si carregues React des d'una etiqueta `<script>`, aquestes APIs de nivell superior estan disponibles en el `ReactDOM` global. Si fas servir ES6 amb npm, pots escriure `import ReactDOM from 'react-dom'`. Si utilitzes ES5 amb npm, pots escriure `var ReactDOM = require('react-dom')`.
1010

11-
## Overview {#overview}
11+
## Resum {#overview}
1212

13-
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.
13+
El paquet `react-dom` proporciona mètodes específics del DOM que pots fer servir al nivell superior de la teva aplicació i com a escotilla per sortir del model React si cal. La majoria dels components no han de fer servir aquest mòdul.
1414

1515
- [`render()`](#render)
1616
- [`hydrate()`](#hydrate)
1717
- [`unmountComponentAtNode()`](#unmountcomponentatnode)
1818
- [`findDOMNode()`](#finddomnode)
1919
- [`createPortal()`](#createportal)
2020

21-
### Browser Support {#browser-support}
21+
### Navegadors Compatibles {#browser-support}
2222

23-
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.
23+
React és compatible amb tots els navegadors populars, incloent-hi Internet Explorer 9 i superiors, tot i que [fan falta alguns *polyfills*](/docs/javascript-environment-requirements.html) per als navegadors més antics com ara l'IE 9 i l'IE 10.
2424

25-
> Note
25+
> Nota
2626
>
27-
> 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.
27+
> No garantim la compatibilitat amb els navegadors més antics que no suporten els mètodes ES5, però és possible que les teves aplicacions funcionin en navegadors més antics si els *polyfills* com ara [es5-shim i es5-sham](https://github.com/es-shims/es5-shim) s'inclouen a la pàgina. Si decideixes prendre aquest camí recorda que és sota la teva responsabilitat.
2828
2929
* * *
3030

31-
## Reference {#reference}
31+
## Referències {#reference}
3232

3333
### `render()` {#render}
3434

3535
```javascript
36-
ReactDOM.render(element, container[, callback])
36+
ReactDOM.render(element, callback[, callback])
3737
```
3838

39-
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#function-and-class-components)).
39+
Renderitza un element React al DOM en el *callback* subministrat i retorna un [referència](/docs/more-about-refs.html) al component (o retorna `null` per a [components sense estat](/docs/components-and-props.html#function-and-class-components)).
4040

41-
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.
41+
Si l'element React s'ha renderitzat prèviament en el *callback*, en farà la seva actualització i només canviarà del DOM el que sigui necessari per reflectir l'últim element de React.
4242

43-
If the optional callback is provided, it will be executed after the component is rendered or updated.
43+
Si es proporciona la *callback* opcional, s'executarà després que el component es renderitzi o s'actualitzi.
4444

45-
> Note:
45+
> Nota:
4646
>
47-
> `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.
47+
> `ReactDOM.render()` controla el contingut del node *callback* que s'hi passi. Qualsevol altre element DOM que sigui al seu interior es substitueix quan es crida per primer cop. Les crides posteriors fan servir l'algoritme de comparació del DOM de React per fer actualitzacions eficients.
4848
>
49-
> `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.
49+
> `ReactDOM.render()` no modifica el node contenidor (només modifica els fills del contenidor). És possible inserir un component a un node DOM que ja existeix sense sobreescriure els fills existents.
5050
>
51-
> `ReactDOM.render()` currently returns a reference to the root `ReactComponent` instance. However, using this return value is legacy
52-
> 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
53-
> [callback ref](/docs/more-about-refs.html#the-ref-callback-attribute) to the root element.
51+
> `ReactDOM.render()` actualment retorna una referència a la instància arrel `ReactComponent`. No obstant això, fer servir aquest valor de retorn és obsolet
52+
> i s'ha d'evitar perquè les versions futures de React podran representar els components de forma asíncrona en alguns casos. Si necessites una referència a la instància arrel `ReactComponent`, la solució idònia és adjuntar una
53+
> [callback ref](/docs/more-about-refs.html#the-ref-callback-attribute) a l'element arrel.
5454
>
55-
> Using `ReactDOM.render()` to hydrate a server-rendered container is deprecated and will be removed in React 17. Use [`hydrate()`](#hydrate) instead.
55+
> Fer servir `ReactDOM.render()` per hidratar un contenidor amb renderització des del servidor és obsolet i s'eliminarà a la versió 17 de React. Fes servir en el seu lloc [`hydrate()`](#hydrate).
5656
5757
* * *
5858

5959
### `hydrate()` {#hydrate}
6060

6161
```javascript
62-
ReactDOM.hydrate(element, container[, callback])
62+
ReactDOM.hydrate(element, callback[, callback])
6363
```
6464

65-
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.
65+
El mateix que [`render()`](#render), però s'utilitza per 'hidratar' un contenidor el contingut HTML del qual ha sigut renderitzat per [`ReactDOMServer`](/docs/react-dom-server.html). React provarà d'adjuntar detectors d'esdeveniments al marcador existent.
6666

67-
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.
67+
React espera que el contingut renderitzat sigui idèntic entre el servidor i el client. Pot corregir les diferències del contingut de text, però hauràs de tractar les discordances com errors i solucionar-les. En el mode de desenvolupament, React adverteix sobre les discordances durant la hidratació. No hi ha garantia que les diferències d'atribut siguin arreglades en cas de discordança. Això és important per raons de rendiment perquè a la majoria d'aplicacions són rares les discordances, i per tant, validar tots els marcadors tindria un cost massa alt.
6868

69-
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.
69+
Si l'atribut d'un sol element o el contingut del text és inevitablement diferent entre el servidor i el client (per exemple, una marca de temps), pots silenciar l'avís afegint `suppressHydrationWarning={true}` a l'element. Només funciona amb un nivell de profunditat, i està destinat a ser una via de escapatòria. No n'abusis. Tret que sigui contingut de text, React no intentarà corregir-ho, de manera que pot ser que no sigui coherent fins a futures actualitzacions.
7070

71-
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.
71+
Si has de representar intencionadament quelcom diferent del servidor al client, pots fer-la en dos passos. Els components que renderitzen quelcom diferent del client poden llegir una variable d'estat com ara `this.state.isClient`, que pots establir a `true` dins de `componentDidMount()`. D'aquesta manera, en el pas inicial es renderitzarà el mateix contingut que en el servidor, evitant discordances i just després de la hidratació es renderitzarà síncronament un segon pas addicional. Tingues en compte que aquest enfocament farà que els teus components siguin més lents perquè s'han de renderitzar dues vegades, per tant fes-lo servir amb cura.
7272

73-
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.
73+
Recorda tenir en compte l'experiència d'usuari en connexions lentes. El codi JavaScript es pot carregar força més tard que la renderització HTML inicial, de manera que si es renderitza alguna cosa diferent només en la part del client, la transició pot ser que grinyoli. Tot i això, si s'executa bé, pot ser beneficiós representar una shell de l'aplicació al servidor, i només mostrar alguns dels ginys addicionals en el client. Per a aprendre a fer-ho sense que hi hagi problemes de discordances, consulta l'explicació del paràgraf anterior.
7474

7575
* * *
7676

7777
### `unmountComponentAtNode()` {#unmountcomponentatnode}
7878

7979
```javascript
80-
ReactDOM.unmountComponentAtNode(container)
80+
ReactDOM.unmountComponentAtNode(callback)
8181
```
8282

83-
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.
83+
Elimina un component de React muntat des del DOM i neteja els seus gestors d’esdeveniments i estat. Si no s'ha muntat cap component al contenidor, la crida a aquesta funció no fa res. Retorna `true` si un component s'ha desmuntat i `false` si no hi ha cap component per desmuntar.
8484

8585
* * *
8686

8787
### `findDOMNode()` {#finddomnode}
8888

89-
> Note:
89+
> Nota:
9090
>
91-
> `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)
91+
> `findDOMNode` és una escotilla de sortida feta servir per accedir al node DOM subjacent. En la majoria dels casos, l'ús d'aquesta sortida es desaconsella perquè trenca l'abstracció del component. [Ha quedat obsolet a l'`StrictMode`.](/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage)
9292
9393
```javascript
9494
ReactDOM.findDOMNode(component)
9595
```
96-
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.**
96+
Si aquest component s'ha muntat en el DOM, retorna l'element corresponent del navegador natiu del DOM. Aquest mètode és útil per llegir els valors fora del DOM, com ara els valors de formulari i fer mesuraments de DOM. **En la majoria dels casos, pots adjuntar una referència al node DOM i així evitar utilitzar `find DOMNode`.**
9797

98-
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.
98+
Quan un component es renderitza a `null` o `false`, `findDOMNode` retorna `null`. Quan un component es renderitza a una cadena, `findDOMNode` retorna un node DOM que conté aquest valor. A partir de React 16, un component pot retornar un fragment amb diversos fills, en aquest cas `findDOMNode` retornarà el node DOM corresponent al primer fill que no estigui buit.
9999

100-
> Note:
100+
> Nota:
101101
>
102-
> `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.
102+
> `findDOMNode` només funciona amb components muntats (és a dir, components que s'han col·locat en el DOM). Si ho intentes amb un component que encara no s'ha muntat (com ara cridar `findDOMNode()` dins de `render()` en un component que encara no s'ha creat) es llançarà una excepció.
103103
>
104-
> `findDOMNode` cannot be used on function components.
104+
> `findDOMNode` no es pot fer servir en components funcionals.
105105
106106
* * *
107107

108108
### `createPortal()` {#createportal}
109109

110110
```javascript
111-
ReactDOM.createPortal(child, container)
111+
ReactDOM.createPortal(child, callback)
112112
```
113113

114-
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).
114+
Crea un portal. Els portals proporcionen una manera de [renderitzar els fills en un node DOM que existeix fora de la jerarquia del component DOM](/docs/portals.html).

0 commit comments

Comments
 (0)