Skip to content

docs: translation for useId - #524

Merged
zainfathoni merged 9 commits into
reactjs:mainfrom
AndriP8:translate-useid
Jul 30, 2023
Merged

docs: translation for useId#524
zainfathoni merged 9 commits into
reactjs:mainfrom
AndriP8:translate-useid

Conversation

@AndriP8

Copy link
Copy Markdown
Contributor

Closes#402

Description

Translate the useId page.
Page URL: https://id.react.dev/reference/react/useId

Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
@github-actions

github-actionsBot commented May 1, 2023

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@zainfathonizainfathoni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More terms to introduce in the glossary, @resir014@r17x@mhaidarhanif@mazipan

EnglishIndonesian
hardcodekode keras (?), menuliskan secara langsung di dalam kode
server renderingpe-render-an pada server
prefixawalan
suffixakhiran

Let's discuss them here: #337 (comment)

Comment threadsrc/content/reference/react/useId.md Outdated
#### Caveats {/*caveats*/}

* `useId` is a Hook, so you can only call it **at the top level of your component** or your own Hooks. You can't call it inside loops or conditions. If you need that, extract a new component and move the state into it.
* `useId` adalah sebuah Hook, jadi Anda hanya dapat memanggilnya **di tingkat atas komponen Anda** atau Hook Anda sendiri. Anda tidak dapat memanggilnya di dalam loop atau kondisi. Jika Anda membutuhkannya, ekstrak komponen baru dan pindahkan *state* ke dalamnya.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*`useId` adalah sebuah Hook, jadi Anda hanya dapat memanggilnya **di tingkat atas komponen Anda** atau Hook Anda sendiri. Anda tidak dapat memanggilnya di dalam loop atau kondisi. Jika Anda membutuhkannya, ekstrak komponen baru dan pindahkan *state* ke dalamnya.
*`useId` adalah sebuah Hook, jadi Anda hanya dapat memanggilnya **di tingkat teratas komponen Anda** atau Hook Anda sendiri. Anda tidak dapat memanggilnya di dalam perulangan (*loops*) atau kondisi (*conditions*). Jika Anda membutuhkannya, ekstrak komponen baru dan pindahkan *state* ke dalamnya.

Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
```

However, hardcoding IDs like this is not a good practice in React. A component may be rendered more than once on the page--but IDs have to be unique! Instead of hardcoding an ID, generate a unique ID with `useId`:
Namun, memaksakan ID seperti ini bukanlah praktik yang baik di React. Sebuah komponen dapat dirender lebih dari sekali pada halaman—namun ID harus unik! Alih-alih melakukan pemaksaan ID, buat ID unik dengan `useId`:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Namun, memaksakan ID seperti ini bukanlah praktik yang baik di React. Sebuah komponen dapat dirender lebih dari sekali pada halaman—namun ID harus unik! Alih-alih melakukan pemaksaan ID, buat ID unik dengan `useId`:
Namun, menuliskan ID secara langsung di dalam kode (*hardcoding*) seperti ini bukanlah praktik yang baik di React. Sebuah komponen dapat dirender lebih dari sekali pada halaman—namun ID harus unik! Alih-alih melakukan pemaksaan ID, bangkitkan sebuah ID unik dengan `useId`:

Comment threadsrc/content/reference/react/useId.md Outdated
<Pitfall>

With [server rendering](/reference/react-dom/server), **`useId` requires an identical component tree on the server and the client**. If the trees you render on the server and the client don't match exactly, the generated IDs won't match.
Dengan [rendering server](/reference/react-dom/server), **`useId` membutuhkan pohon komponen yang identik di server dan klien**. Jika pohon yang Anda render di server dan klien tidak sama persis, ID yang dihasilkan tidak akan cocok.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Dengan [rendering server](/reference/react-dom/server), **`useId` membutuhkan pohon komponen yang identik di server dan klien**. Jika pohon yang Anda render di server dan klien tidak sama persis, ID yang dihasilkan tidak akan cocok.
Dengan [pe-*render*-an pada *server*](/reference/react-dom/server), **`useId` membutuhkan pohon komponen yang identik di *server* dan klien**. Jika pohon yang Anda *render* di *server* dan klien tidak sama persis, ID yang dihasilkan tidak akan cocok.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't fix it because the word pe-*render*-an is still under discussion

Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
r17x
r17x approved these changes May 3, 2023
@r17x

r17x commented May 7, 2023

Copy link
Copy Markdown
Collaborator

Need to re-check @zainfathoni

Comment threadsrc/content/reference/react/useId.md Outdated
@mazipan

Copy link
Copy Markdown
Collaborator

Waiting your approval, @zainfathoni

@zainfathoni

Copy link
Copy Markdown
Collaborator

Okay, I'll review it tonight.

@zainfathonizainfathoni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing some of my previously requested changes.
Here is another review of the unaddressed change requests.

Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
Comment threadsrc/content/reference/react/useId.md Outdated
@AndriP8
AndriP8 requested a review from zainfathoniMay 10, 2023 01:51
@r17x

r17x commented Jun 29, 2023

Copy link
Copy Markdown
Collaborator

@zainfathoni need to recheck latest changes

@resir014

Copy link
Copy Markdown
Member

@zainfathoni do you have time for re-review?

@zainfathoni

Copy link
Copy Markdown
Collaborator

@zainfathoni do you have time for re-review?

Yes, I will have some time to review this weekend. Sorry for the delay. 🙏

@zainfathonizainfathoni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a minor suggestion. 💯
Thanks for making the requested changes! 🙏

Comment threadsrc/content/reference/react/useId.md Outdated
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useId

6 participants

@AndriP8@r17x@mazipan@zainfathoni@resir014@mhaidarhanif