Skip to content

Translation for the page 'React.Component' #118

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 9 commits into from
Mar 18, 2019
1 change: 1 addition & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Suggestion on words and terms:
| React component class | classe componente React |
| React component type | tipo componente React |
| function component | componente funzione |
| error boundary | contenitore di errori |

## Problematic terms

Expand Down
2 changes: 1 addition & 1 deletion content/community/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ April 12, 2019 in Amsterdam, The Netherlands

[Website](https://react.amsterdam) - [Twitter](https://twitter.com/reactamsterdam) - [Facebook](https://www.facebook.com/reactamsterdam)

### ReactJS Girls Conference
### ReactJS Girls Conference {#reactjs-girls-conference}
May 3, 2019 in London, UK

[Website](https://reactjsgirls.com/) - [Twitter](https://twitter.com/reactjsgirls)
Expand Down
4 changes: 2 additions & 2 deletions content/docs/code-splitting.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ function MyComponent() {
}
```

### Error boundaries {#error-boundaries}
### Contenitori di Errori {#error-boundaries}

If the other module fails to load (for example, due to network failure), it will trigger an error. You can handle these errors to show a nice user experience and manage recovery with [Error Boundaries](/docs/error-boundaries.html). Once you've created your Error Boundary, you can use it anywhere above your lazy components to display an error state when there's a network error.
If the other module fails to load (for example, due to network failure), it will trigger an error. You can handle these errors to show a nice user experience and manage recovery with [Contenitori di Errori](/docs/error-boundaries.html). Once you've created your Contenitore di Errori, you can use it anywhere above your lazy components to display an error state when there's a network error.

```js
import MyErrorBoundary from './MyErrorBoundary';
Expand Down
2 changes: 1 addition & 1 deletion content/docs/codebase-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Its main goals are:
* Ability to prioritize, rebase and reuse work in progress.
* Ability to yield back and forth between parents and children to support layout in React.
* Ability to return multiple elements from `render()`.
* Better support for error boundaries.
* Migliore supporto per i contenitori di errori.

You can read more about React Fiber Architecture [here](https://github.com/acdlite/react-fiber-architecture) and [here](https://medium.com/react-in-depth/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react-e1c04700ef6e). While it has shipped with React 16, the async features are not enabled by default yet.

Expand Down
2 changes: 1 addition & 1 deletion content/docs/error-boundaries.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: error-boundaries
title: Error Boundaries
title: Contenitori di Errori
permalink: docs/error-boundaries.html
---

Expand Down
2 changes: 1 addition & 1 deletion content/docs/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
- id: context
title: Context
- id: error-boundaries
title: Error Boundaries
title: Contenitori di Errori
- id: forwarding-refs
title: Forwarding Refs
- id: fragments
Expand Down
2 changes: 1 addition & 1 deletion content/docs/react-without-es6.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: react-without-es6
title: React Without ES6
title: React senza ES6
permalink: docs/react-without-es6.html
---

Expand Down
420 changes: 210 additions & 210 deletions content/docs/reference-react-component.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content/docs/reference-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ React components let you split the UI into independent, reusable pieces, and thi
- [`React.Component`](#reactcomponent)
- [`React.PureComponent`](#reactpurecomponent)

If you don't use ES6 classes, you may use the `create-react-class` module instead. See [Using React without ES6](/docs/react-without-es6.html) for more information.
If you don't use ES6 classes, you may use the `create-react-class` module instead. See [React senza ES6](/docs/react-without-es6.html) for more information.

React components can also be defined as functions which can be wrapped:

Expand Down
40 changes: 25 additions & 15 deletions examples/react-component-reference/get-snapshot-before-update.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
class ScrollingList extends React.Component {
class ListaScorrimento extends React.Component {
constructor(props) {
super(props);
this.listRef = React.createRef();
this.rifLista = React.createRef();
}

getSnapshotBeforeUpdate(prevProps, prevState) {
// Are we adding new items to the list?
// Capture the scroll position so we can adjust scroll later.
if (prevProps.list.length < this.props.list.length) {
const list = this.listRef.current;
return list.scrollHeight - list.scrollTop;
getSnapshotBeforeUpdate(
propsPrecedenti,
statePrecedente
) {
// Stiamo aggiungendo nuovi elementi alla lista?
// Salviamo la posizione dello scroll in modo da poterla aggiustare in seguito.
if (
propsPrecedenti.list.length < this.props.list.length
) {
const lista = this.rifLista.current;
return lista.scrollHeight - lista.scrollTop;
}
return null;
}

componentDidUpdate(prevProps, prevState, snapshot) {
// If we have a snapshot value, we've just added new items.
// Adjust scroll so these new items don't push the old ones out of view.
// (snapshot here is the value returned from getSnapshotBeforeUpdate)
componentDidUpdate(
propsPrecedenti,
statePrecedente,
snapshot
) {
// Se snapshot è definito, abbiamo appenan aggiunto nuovi elementi alla lista.
// Aggiustiamo lo scroll in modo che i nuovi elementi non spingano quelli
// preesistenti fuori dallo schermo.
// (snapshot contiene il valore restituito da getSnapshotBeforeUpdate)
if (snapshot !== null) {
const list = this.listRef.current;
list.scrollTop = list.scrollHeight - snapshot;
const lista = this.rifLista.current;
lista.scrollTop = lista.scrollHeight - snapshot;
}
}

render() {
return (
<div ref={this.listRef}>{/* ...contents... */}</div>
<div ref={this.rifLista}>{/* ...contenuti... */}</div>
);
}
}