You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/state-as-a-snapshot.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -324,9 +324,9 @@ A co, jeśli chcesz odczytać najnowszy stan przed ponownym renderowaniem? Wtedy
324
324
325
325
<Challenges>
326
326
327
-
#### Implement a traffic light {/*implement-a-traffic-light*/}
327
+
#### Zaimplementuj światła uliczne {/*implement-a-traffic-light*/}
328
328
329
-
Here is a crosswalk light component that toggles when the button is pressed:
329
+
Oto komponent świateł na przejściu dla pieszych, który przełącza się po naciśnięciu przycisku:
330
330
331
331
<Sandpack>
332
332
@@ -343,12 +343,12 @@ export default function TrafficLight() {
343
343
return (
344
344
<>
345
345
<button onClick={handleClick}>
346
-
Change to {walk ?'Stop':'Walk'}
346
+
Zmień na {walk ?'Stój':'Idź'}
347
347
</button>
348
348
<h1 style={{
349
349
color: walk ?'darkgreen':'darkred'
350
350
}}>
351
-
{walk ?'Walk':'Stop'}
351
+
{walk ?'Idź':'Stój'}
352
352
</h1>
353
353
</>
354
354
);
@@ -361,13 +361,13 @@ h1 { margin-top: 20px; }
361
361
362
362
</Sandpack>
363
363
364
-
Add an `alert`to the click handler. When the light is green and says "Walk", clicking the button should say "Stop is next". When the light is red and says "Stop", clicking the button should say "Walk is next".
364
+
Dodaj `alert`do procedury obsługi kliknięcia. Kiedy światło jest zielone i wyświetla "Idź", kliknięcie przycisku powinno pokazać "Następnie będzie Stój". Kiedy światło jest czerwone i wyświetla "Stój", kliknięcie przycisku powinno pokazać "Następnie będzie Idź".
365
365
366
-
Does it make a difference whether you put the `alert`before or after the`setWalk` call?
366
+
Czy ma znaczenie, czy umieścisz `alert`przed czy po wywołaniu`setWalk`?
367
367
368
368
<Solution>
369
369
370
-
Your`alert`should look like this:
370
+
Twój`alert`powinien wyglądać tak:
371
371
372
372
<Sandpack>
373
373
@@ -379,18 +379,18 @@ export default function TrafficLight() {
379
379
380
380
functionhandleClick() {
381
381
setWalk(!walk);
382
-
alert(walk ?'Stop is next':'Walk is next');
382
+
alert(walk ?'Następnie będzie Stój':'Następnie będzie Idź');
383
383
}
384
384
385
385
return (
386
386
<>
387
387
<button onClick={handleClick}>
388
-
Change to {walk ?'Stop':'Walk'}
388
+
Zmień na {walk ?'Stój':'Idź'}
389
389
</button>
390
390
<h1 style={{
391
391
color: walk ?'darkgreen':'darkred'
392
392
}}>
393
-
{walk ?'Walk':'Stop'}
393
+
{walk ?'Idź':'Stój'}
394
394
</h1>
395
395
</>
396
396
);
@@ -403,31 +403,31 @@ h1 { margin-top: 20px; }
403
403
404
404
</Sandpack>
405
405
406
-
Whether you put it before or after the `setWalk` call makes no difference. That render's value of `walk`is fixed. Calling`setWalk`will only change it for the *next* render, but will not affect the event handler from the previous render.
406
+
Nie ma znaczenia, czy umieścisz alert przed czy po wywołaniu `setWalk`. Wartość `walk`dla tego renderowania jest ustalona. Wywołanie`setWalk`zmieni ją tylko dla *następnego* renderowania, ale nie wpłynie na procedurę obsługi zdarzeń z poprzedniego renderowania.
407
407
408
-
This line might seem counter-intuitive at first:
408
+
Ta linia może początkowo wydawać się nieintuicyjna:
409
409
410
410
```js
411
-
alert(walk ?'Stop is next':'Walk is next');
411
+
alert(walk ?'Następnie będzie Stój':'Następnie będzie Idź');
412
412
```
413
413
414
-
But it makes sense if you read it as: "If the traffic light shows 'Walk now', the message should say 'Stop is next.'" The`walk`variable inside your event handler matches that render's value of `walk`and does not change.
414
+
Ale ma ona sens, jeśli przeczytasz ją tak: "Jeśli sygnalizator pokazuje 'Idź', komunikat powinien brzmieć 'Następnie będzie Stój'". Zmienna`walk`wewnątrz procedury obsługi zdarzeń odpowiada wartości `walk`z tego renderowania i nie zmienia się.
415
415
416
-
You can verify that this is correct by applying the substitution method. When`walk`is `true`, you get:
416
+
Możesz to zweryfikować, stosując metodę podstawiania. Kiedy`walk`ma wartość `true`, otrzymujesz:
417
417
418
418
```js
419
419
<button onClick={() => {
420
420
setWalk(false);
421
-
alert('Stop is next');
421
+
alert('Następnie będzie Stój');
422
422
}}>
423
-
Change to Stop
423
+
Zmień na Stój
424
424
</button>
425
425
<h1 style={{color:'darkgreen'}}>
426
-
Walk
426
+
Idź
427
427
</h1>
428
428
```
429
429
430
-
So clicking "Change to Stop" queues a render with `walk`set to`false`, and alerts "Stop is next".
430
+
Więc kliknięcie "Zmień na Stój" dodaje do kolejki renderowanie z `walk`ustawionym na`false` i wyświetla alert "Następnie będzie Stój".
0 commit comments