Skip to content

Commit 567ec1f

Browse files
tjgeniresir014
andcommitted
Translate Context (#131)
translate 'Context' section to be Indonesian Language Co-Authored-By: Resi Respati <[email protected]>
1 parent d7c732e commit 567ec1f

9 files changed

+101
-100
lines changed

content/docs/context.md

Lines changed: 70 additions & 69 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+
// komponen Toolbar harus menggunakan *prop* "theme" tambahan
10+
// dan oper ke ThemedButton. Ini bisa menjadi *painful*
11+
// jika setiap tombol di dalam aplikasi perlu mengetahui *theme*-nya
12+
// karena itu harus melewati semua komponen.
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+
// Context memungkinkan kita untuk oper nilai ke dalam diagram komponen
3+
// tanpa secara ekplisit memasukannya ke dalam setiap komponen.
4+
// Buat *context* untuk tema saat ini (dengan "light" sebagai default).
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+
// Gunakan Provider untuk oper tema saat ini ke diagram di bawah ini.
11+
// Komponen apa pun dapat membacanya, tidak peduli seberapa dalam diagram tersebut.
12+
// Dalam contoh ini, kita mengoper "dark" sebagai nilai saat ini.
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+
// Komponen di tengah tidak harus
23+
// oper temanya secara ekplisit lagi.
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+
// Tetapkan contextType untuk membaca *context theme* saat ini.
35+
// React akan menemukan Provider *theme* terdekat di atas dan menggunakan nilainya.
36+
// Dalam contoh ini, *theme* saat ini adalah "dark".
3737
static contextType = ThemeContext;
3838
render() {
3939
return <Button theme={this.context} />;

examples/context/multiple-contexts.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Theme context, default to light theme
1+
// Context Theme, default theme-nya light
22
const ThemeContext = React.createContext('light');
33

4-
// Signed-in user context
4+
// Context pengguna yang masuk
55
const UserContext = React.createContext({
66
name: 'Guest',
77
});
@@ -10,7 +10,7 @@ class App extends React.Component {
1010
render() {
1111
const {signedInUser, theme} = this.props;
1212

13-
// App component that provides initial context values
13+
// Komponen App yang menyediakan nilai *context* awal
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+
// Komponen dapat menggunakan banyak *context*
3535
function Content() {
3636
// highlight-range{2-10}
3737
return (

examples/context/theme-detailed-app.js

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

4-
// An intermediate component that uses the ThemedButton
4+
// Komponen perantara yang menggunakan ThemedButton
55
function Toolbar(props) {
66
return (
77
<ThemedButton onClick={props.changeTheme}>
@@ -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+
// Tombol ThemedButton di dalam ThemeProvider
33+
// menggunakan tema dari *state* sedangkan yang di luar menggunakan
34+
// theme dark default
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 // nilai *default*
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+
// State juga berisi fungsi pembaruan yang akan
19+
// diturunkan kedalam *provider context*
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+
// Seluruh *state* diteruskan ke *provider*
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+
// Pastikan bentuk nilai default yang di oper ke
2+
// createContext cocok dengan bentuk yang di harapkan *consumer*!
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ 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+
// Theme Toggler Button tidak hanya menerima *theme*
6+
// tetapi juga fungsi toggleTheme dari *context*
77
return (
88
<ThemeContext.Consumer>
99
{({theme, toggleTheme}) => (

0 commit comments

Comments
 (0)