Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 267
Translated React Without ES6#49
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,54 +1,54 @@ | ||||||
| --- | ||||||
| id: react-without-es6 | ||||||
| title: React Without ES6 | ||||||
| title: React Tanpa ES6 | ||||||
| permalink: docs/react-without-es6.html | ||||||
| --- | ||||||
| Normally you would define a React component as a plain JavaScript class: | ||||||
| Umumnya Anda mendefinisikan komponen React sebagai kelas JavaScript biasa: | ||||||
| ```javascript | ||||||
| class Greeting extends React.Component { | ||||||
| render() { | ||||||
| return <h1>Hello, {this.props.name}</h1>; | ||||||
| return <h1>Halo {this.props.name}</h1>; | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
| If you don't use ES6 yet, you may use the `create-react-class` module instead: | ||||||
| Jika Anda belum menggunakan ES6, Anda bisa menggunakan modul `create-react-class`: | ||||||
| ```javascript | ||||||
| var createReactClass = require('create-react-class'); | ||||||
| var Greeting = createReactClass({ | ||||||
| render: function() { | ||||||
| return <h1>Hello, {this.props.name}</h1>; | ||||||
| return <h1>Halo {this.props.name}</h1>; | ||||||
| } | ||||||
| }); | ||||||
| ``` | ||||||
| The API of ES6 classes is similar to `createReactClass()` with a few exceptions. | ||||||
| API untuk kelas ES6 mirip dengan `createReactClass()`, dengan beberapa pengecualian. | ||||||
| ## Declaring Default Props {#declaring-default-props} | ||||||
| ## Mendeklarasikan *Props* *Default* {#declaring-default-props} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
| ||||||
| With functions and ES6 classes `defaultProps` is defined as a property on the component itself: | ||||||
| Dengan kelas dan fungsi ES6, `defaultProps` didefinisikan sebagai properti komponennya sendiri: | ||||||
| ```javascript | ||||||
| class Greeting extends React.Component { | ||||||
| // ... | ||||||
| } | ||||||
| Greeting.defaultProps = { | ||||||
| name: 'Mary' | ||||||
| name: 'Maria' | ||||||
| }; | ||||||
| ``` | ||||||
| With `createReactClass()`, you need to define `getDefaultProps()` as a function on the passed object: | ||||||
| Dengan `createReactClass()`, Anda harus mendefinisikan `getDefaultProps()` sebagai fungsi pada objek yang dioperkan: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which one sounds better?
Suggested change
| ||||||
| ```javascript | ||||||
| var Greeting = createReactClass({ | ||||||
| getDefaultProps: function() { | ||||||
| return { | ||||||
| name: 'Mary' | ||||||
| name: 'Maria' | ||||||
| }; | ||||||
| }, | ||||||
| @@ -57,9 +57,9 @@ var Greeting = createReactClass({ | ||||||
| }); | ||||||
| ``` | ||||||
| ## Setting the Initial State {#setting-the-initial-state} | ||||||
| ## Menyetel *State* Awal {#setting-the-initial-state} | ||||||
| ||||||
| ## Menyetel *State* Awal {#setting-the-initial-state} | |
| ## Mengatur State Awal {#setting-the-initial-state} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ## *Autobinding* {#autobinding} | |
| ## Autobinding {#autobinding} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instans -> instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Pada komponen React yang dideklarasikan sebagai kelas ES6, *method* mengikuti semantik yang sama seperti kelas ES6 reguler. Ini berarti *method* tersebut tidak secara otomatis mem-*bind*`this` kepada instans. Anda harus secara eksplisit menggunakan `.bind(this)` pada konstruktor: | |
| Pada komponen React yang dideklarasikan sebagai kelas ES6, *method* mengikuti semantik yang sama seperti kelas ES6 reguler. Ini berarti *method* tersebut tidak secara otomatis mem-*bind*`this` kepada *instance*. Anda harus secara eksplisit menggunakan `.bind(this)` pada konstruktor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sintaksis typo I think 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // PERINGATAN: sintalsis ini bersifat eksperimental! | |
| // PERINGATAN: sintaksis ini bersifat eksperimental! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Jika Anda ingin bermain pada area yang aman, Anda memiliki beberapa opsi: | |
| Jika Anda ingin bermain aman, Anda memiliki beberapa opsi: |
Also, should idioms like play it safe be translated as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| *Terus gunakan`createReactClass`. | |
| *Tetap menggunakan`createReactClass`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| >**Kami juga menemukan banyak masalah pada kode dasar yang menggunakan *mixin*, [dan tidak menyarankan untuk menggunakannya untuk kode yang baru](/blog/2016/07/13/mixins-considered-harmful.html).** | |
| >**Kami juga menemukan banyak masalah pada basis kode yang menggunakan *mixin*, [dan tidak menyarankan untuk menggunakannya untuk kode yang baru](/blog/2016/07/13/mixins-considered-harmful.html).** |
What do you think? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Jika komponen menggunakan beberapa *mixin* dan beberapa *mixin* mendefinisikan *lifecycle method* yang sama (beberapa *mixin* ingin melakukan pembersihan ketika komponen dihancurkan), semua *lifecycle method* dijamin untuk dipanggil. *Method* yang didefiniskan pada *mixin* dijalankan secara berurutan sesuai dengan dengan proses pendaftarannya, diikuti dengan pemanggilan *method* pada komponen. | |
| Jika komponen menggunakan beberapa *mixin* dan beberapa *mixin* mendefinisikan *lifecycle method* yang sama (contohnya, beberapa *mixin* ingin melakukan pembersihan ketika komponen dihancurkan), semua *lifecycle method* dijamin untuk dipanggil. *Method* yang didefinisikan pada *mixin* dijalankan secara berurutan sesuai dengan dengan proses pendaftarannya, diikuti dengan pemanggilan *method* pada komponen. |
Several typos I think 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loanwords in the heading doesn't have to be italicized 😄