Skip to content

Commit db1b041

Browse files
committed
setting-state-triggers-renders
1 parent 5c2a694 commit db1b041

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/content/learn/state-as-a-snapshot.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Zmienne stanu mogą wyglądać jak zwykłe zmienne javascriptowe, które można
1717

1818
</YouWillLearn>
1919

20-
## Setting state triggers renders {/*setting-state-triggers-renders*/}
20+
## Ustawianie stanu wyzwala ponowne renderowanie {/*setting-state-triggers-renders*/}
2121

22-
You might think of your user interface as changing directly in response to the user event like a click. In React, it works a little differently from this mental model. On the previous page, you saw that [setting state requests a re-render](/learn/render-and-commit#step-1-trigger-a-render) from React. This means that for an interface to react to the event, you need to *update the state*.
22+
Możesz myśleć, że twój interfejs użytkownika zmienia się bezpośrednio w odpowiedzi na zdarzenie użytkownika, takie jak kliknięcie. W Reakcie działa to nieco inaczej. Na poprzedniej stronie zobaczyłeś, że [ustawienie stanu wysyła żądanie ponownego renderowania](/learn/render-and-commit#step-1-trigger-a-render) do Reacta. Oznacza to, że aby interfejs zareagował na zdarzenie, musisz *zaktualizować stan*.
2323

24-
In this example, when you press "send", `setIsSent(true)` tells React to re-render the UI:
24+
W tym przykładzie, gdy naciśniesz "Wyślij", wywołanie `setIsSent(true)` informuje Reacta, aby ponownie wyrenderował interfejs użytkownika:
2525

2626
<Sandpack>
2727

@@ -30,9 +30,9 @@ import { useState } from 'react';
3030

3131
export default function Form() {
3232
const [isSent, setIsSent] = useState(false);
33-
const [message, setMessage] = useState('Hi!');
33+
const [message, setMessage] = useState('Cześć!');
3434
if (isSent) {
35-
return <h1>Your message is on its way!</h1>
35+
return <h1>Twoja wiadomość jest w drodze!</h1>
3636
}
3737
return (
3838
<form onSubmit={(e) => {
@@ -41,11 +41,11 @@ export default function Form() {
4141
sendMessage(message);
4242
}}>
4343
<textarea
44-
placeholder="Message"
44+
placeholder="Wiadomość"
4545
value={message}
4646
onChange={e => setMessage(e.target.value)}
4747
/>
48-
<button type="submit">Send</button>
48+
<button type="submit">Wyślij</button>
4949
</form>
5050
);
5151
}
@@ -61,13 +61,13 @@ label, textarea { margin-bottom: 10px; display: block; }
6161

6262
</Sandpack>
6363

64-
Here's what happens when you click the button:
64+
Oto co dzieje się, gdy klikniesz przycisk:
6565

66-
1. The `onSubmit` event handler executes.
67-
2. `setIsSent(true)` sets `isSent` to `true` and queues a new render.
68-
3. React re-renders the component according to the new `isSent` value.
66+
1. Wykonuje się procedura obsługi zdarzenia `onSubmit`.
67+
2. Wywołanie `setIsSent(true)` ustawia `isSent` na `true` i dodaje do kolejki nowe renderowanie.
68+
3. React ponownie renderuje komponent zgodnie z nową wartością `isSent`.
6969

70-
Let's take a closer look at the relationship between state and rendering.
70+
Przyjrzyjmy się bliżej związkowi między stanem a renderowaniem.
7171

7272
## Rendering takes a snapshot in time {/*rendering-takes-a-snapshot-in-time*/}
7373

0 commit comments

Comments
 (0)