Skip to content

Commit f2189b4

Browse files
authored
Translate 'Context' page (#129)
1 parent 9da771e commit f2189b4

11 files changed

+110
-111
lines changed

content/docs/context.md

Lines changed: 74 additions & 75 deletions
Large diffs are not rendered by default.

examples/context/motivation-problem.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ class App extends React.Component {
66

77
function Toolbar(props) {
88
// highlight-range{1-4,7}
9-
// The Toolbar component must take an extra "theme" prop
10-
// and pass it to the ThemedButton. This can become painful
11-
// if every single button in the app needs to know the theme
12-
// because it would have to be passed through all components.
9+
// Komponent `Toolbar` musi przyjmować dodatkową właściwość "theme"
10+
// i przekazywać ją w dół do `ThemedButton`. Gdyby każdy przycisk w aplikacji
11+
// wymagał dostępu do tej wartości, mogłoby to okazać się uciążliwe,
12+
// ponieważ należałoby przekazywać ją przez wszystkie poziomy struktury.
1313
return (
1414
<div>
1515
<ThemedButton theme={props.theme} />

examples/context/motivation-solution.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// highlight-range{1-4}
2-
// Context lets us pass a value deep into the component tree
3-
// without explicitly threading it through every component.
4-
// Create a context for the current theme (with "light" as the default).
2+
// Kontekst pozwala na przekazywanie wartości głęboko do drzewa komponentów
3+
// z pominięciem komponentów pośrednich.
4+
// Stwórzmy kontekst dla aktualnie wybranego motywu (nadając mu domyślną wartość "light" - jasny).
55
const ThemeContext = React.createContext('light');
66

77
class App extends React.Component {
88
render() {
99
// highlight-range{1-3,5}
10-
// Use a Provider to pass the current theme to the tree below.
11-
// Any component can read it, no matter how deep it is.
12-
// In this example, we're passing "dark" as the current value.
10+
// Użyj "dostawcy" (Provider), aby ustawić motyw dla tego poddrzewa aplikacji.
11+
// Każdy komponent będzie mógł go odczytać, nie ważne jak głęboko w drzewie się znajduje.
12+
// W tym przykładzie ustawiamy motyw na "dark" - ciemny.
1313
return (
1414
<ThemeContext.Provider value="dark">
1515
<Toolbar />
@@ -19,8 +19,8 @@ class App extends React.Component {
1919
}
2020

2121
// highlight-range{1,2}
22-
// A component in the middle doesn't have to
23-
// pass the theme down explicitly anymore.
22+
// Komponent pośredni nie musi już jawnie przekazywać tego ustawienia
23+
// w dół hierarchii.
2424
function Toolbar(props) {
2525
return (
2626
<div>
@@ -31,9 +31,9 @@ function Toolbar(props) {
3131

3232
class ThemedButton extends React.Component {
3333
// highlight-range{1-3,6}
34-
// Assign a contextType to read the current theme context.
35-
// React will find the closest theme Provider above and use its value.
36-
// In this example, the current theme is "dark".
34+
// Przypisz wartość do `contextType`, aby odczytać aktualne ustawienie motywu z kontekstu.
35+
// React znajdzie najbliższego dostawcę (Provider) motywu i użyje jego wartości.
36+
// W tym przykładzie aktualny motyw będzie ciemny ("dark").
3737
static contextType = ThemeContext;
3838
render() {
3939
return <Button theme={this.context} />;

examples/context/multiple-contexts.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// Theme context, default to light theme
1+
// Kontekst motywu, domyślnie ustawiony na jasny ("light")
22
const ThemeContext = React.createContext('light');
33

4-
// Signed-in user context
4+
// Kontekst zalogowanego użytkownika
55
const UserContext = React.createContext({
6-
name: 'Guest',
6+
name: 'Gość',
77
});
88

99
class App extends React.Component {
1010
render() {
1111
const {signedInUser, theme} = this.props;
1212

13-
// App component that provides initial context values
13+
// Główny komponent aplikacji, który dostarcza wartości dla kontekstów
1414
// highlight-range{2-3,5-6}
1515
return (
1616
<ThemeContext.Provider value={theme}>
@@ -31,7 +31,7 @@ function Layout() {
3131
);
3232
}
3333

34-
// A component may consume multiple contexts
34+
// Komponent może odczytywać wartości z wielu kontekstów jednocześnie
3535
function Content() {
3636
// highlight-range{2-10}
3737
return (

examples/context/reference-caveats-problem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class App extends React.Component {
22
render() {
33
// highlight-range{2}
44
return (
5-
<Provider value={{something: 'something'}}>
5+
<Provider value={{something: 'coś tam'}}>
66
<Toolbar />
77
</Provider>
88
);

examples/context/reference-caveats-solution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class App extends React.Component {
33
super(props);
44
// highlight-range{2}
55
this.state = {
6-
value: {something: 'something'},
6+
value: {something: 'coś tam'},
77
};
88
}
99

examples/context/theme-detailed-app.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {ThemeContext, themes} from './theme-context';
22
import ThemedButton from './themed-button';
33

4-
// An intermediate component that uses the ThemedButton
4+
// Pośredni komponent, który używa przycisku ThemedButton
55
function Toolbar(props) {
66
return (
77
<ThemedButton onClick={props.changeTheme}>
8-
Change Theme
8+
Zmień motyw
99
</ThemedButton>
1010
);
1111
}
@@ -29,9 +29,9 @@ class App extends React.Component {
2929

3030
render() {
3131
//highlight-range{1-3}
32-
// The ThemedButton button inside the ThemeProvider
33-
// uses the theme from state while the one outside uses
34-
// the default dark theme
32+
// Przycisk ThemedButton wewnątrz komponentu ThemeProvider
33+
// korzysta z motywu przechowywanego w stanie, podczas gdy
34+
// ten zewnętrzny korzysta z domyślnego, ciemnego motywu
3535
//highlight-range{3-5,7}
3636
return (
3737
<Page>

examples/context/theme-detailed-theme-context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export const themes = {
1111

1212
// highlight-range{1-3}
1313
export const ThemeContext = React.createContext(
14-
themes.dark // default value
14+
themes.dark // wartość domyślna
1515
);

examples/context/updating-nested-context-app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class App extends React.Component {
1515
};
1616

1717
// highlight-range{1-2,5}
18-
// State also contains the updater function so it will
19-
// be passed down into the context provider
18+
// Stan zawiera także funkcję aktualizującą,
19+
// która również zostanie przekazana przez dostawcę kontekstu
2020
this.state = {
2121
theme: themes.light,
2222
toggleTheme: this.toggleTheme,
@@ -25,7 +25,7 @@ class App extends React.Component {
2525

2626
render() {
2727
// highlight-range{1,3}
28-
// The entire state is passed to the provider
28+
// Cały stan komponentu jest przekazywany do dostawcy
2929
return (
3030
<ThemeContext.Provider value={this.state}>
3131
<Content />

examples/context/updating-nested-context-context.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Make sure the shape of the default value passed to
2-
// createContext matches the shape that the consumers expect!
1+
// Upewnij się, że kształt wartości domyślnej przekazanej do `createContext`
2+
// odpowiada kształtowi oczekiwanemu przez konsumentów!
33
// highlight-range{2-3}
44
export const ThemeContext = React.createContext({
55
theme: themes.dark,

examples/context/updating-nested-context-theme-toggler-button.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import {ThemeContext} from './theme-context';
22

33
function ThemeTogglerButton() {
44
// highlight-range{1-2,5}
5-
// The Theme Toggler Button receives not only the theme
6-
// but also a toggleTheme function from the context
5+
// Przycisk odczytuje z kontekstu nie tylko aktualny motyw,
6+
// ale także funkcję `toggleTheme` (przełącz motyw)
77
return (
88
<ThemeContext.Consumer>
99
{({theme, toggleTheme}) => (
1010
<button
1111
onClick={toggleTheme}
1212
style={{backgroundColor: theme.background}}>
13-
Toggle Theme
13+
Przełącz motyw
1414
</button>
1515
)}
1616
</ThemeContext.Consumer>

0 commit comments

Comments
 (0)