From 18f7bce2f4506d12112c42a7909765fe12613629 Mon Sep 17 00:00:00 2001 From: Andri Purnomo Date: Mon, 1 May 2023 13:54:03 +0700 Subject: [PATCH 1/7] docs: translation for useId --- src/content/reference/react/useId.md | 62 ++++++++++++++-------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/content/reference/react/useId.md b/src/content/reference/react/useId.md index 4ea029f27a..7a064059e2 100644 --- a/src/content/reference/react/useId.md +++ b/src/content/reference/react/useId.md @@ -4,8 +4,7 @@ title: useId -`useId` is a React Hook for generating unique IDs that can be passed to accessibility attributes. - +`useId` adalah React Hook untuk menghasilkan ID unik yang dapat diteruskan ke atribut aksesibilitas. ```js const id = useId() ``` @@ -16,11 +15,11 @@ const id = useId() --- -## Reference {/*reference*/} +## Referensi {/*reference*/} ### `useId()` {/*useid*/} -Call `useId` at the top level of your component to generate a unique ID: +Panggil `useId` di tingkat atas komponen Anda untuk menghasilkan ID unik: ```js import { useId } from 'react'; @@ -30,35 +29,35 @@ function PasswordField() { // ... ``` -[See more examples below.](#usage) +[Lihat lebih banyak contoh di bawah ini.](#usage) -#### Parameters {/*parameters*/} +#### Parameter {/*parameters*/} -`useId` does not take any parameters. +`useId` tidak mengambil parameter apapun. #### Returns {/*returns*/} -`useId` returns a unique ID string associated with this particular `useId` call in this particular component. +`useId` mengembalikan string ID unik yang terkait dengan panggilan `useId` tertentu dalam komponen khusus ini. #### 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. -* `useId` **should not be used to generate keys** in a list. [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key) +* `useId` **tidak boleh digunakan untuk menghasilkan *key*** dalam daftar. [*Key* harus dihasilkan dari data Anda.](/learn/rendering-lists#where-to-get-your-key) --- -## Usage {/*usage*/} +## Pengunaan {/*usage*/} -**Do not call `useId` to generate keys in a list.** [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key) +**Jangan panggil `useId` untuk menghasilkan *key* dalam daftar.** [*Key* harus dihasilkan dari data Anda](/learn/rendering-lists#where-to-get-your-key) -### Generating unique IDs for accessibility attributes {/*generating-unique-ids-for-accessibility-attributes*/} +### Menghasilkan ID unik untuk atribut aksesibilitas {/*generating-unique-ids-for-accessibility-attributes*/} -Call `useId` at the top level of your component to generate a unique ID: +Panggil `useId` di tingkat atas komponen Anda untuk menghasilkan ID unik: ```js [[1, 4, "passwordHintId"]] import { useId } from 'react'; @@ -68,7 +67,7 @@ function PasswordField() { // ... ``` -You can then pass the generated ID to different attributes: +Anda kemudian dapat meneruskan ID yang dihasilkan ke atribut yang berbeda: ```js [[1, 2, "passwordHintId"], [1, 3, "passwordHintId"]] <> @@ -77,11 +76,11 @@ You can then pass the generated ID to different at ``` -**Let's walk through an example to see when this is useful.** +**Mari telusuri contoh untuk melihat kapan ini berguna.** -[HTML accessibility attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) like [`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) let you specify that two tags are related to each other. For example, you can specify that an element (like an input) is described by another element (like a paragraph). +[Atribut aksesibilitas HTML](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) seperti [`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) membiarkan Anda menentukan bahwa dua tag terkait satu sama lain. Misalnya, Anda dapat menentukan bahwa suatu elemen (seperti input) dijelaskan oleh elemen lain (seperti paragraf). -In regular HTML, you would write it like this: +Dalam HTML biasa, Anda akan menulisnya seperti ini: ```html {5,8}