);
}
-
```
```json package.json hidden
@@ -318,15 +316,15 @@ export default function Search() {
-### Display a form submission error without JavaScript {/*display-a-form-submission-error-without-javascript*/}
+### Menampilkan kesalahan pengiriman formulir tanpa JavaScript {/*display-a-form-submission-error-without-javascript*/}
-Displaying a form submission error message before the JavaScript bundle loads for progressive enhancement requires that:
+Menampilkan pesan kesalahan pengiriman formulir sebelum bundel JavaScript dimuat untuk peningkatan progresif mengharuskan bahwa:
-1. `
` be rendered by a [Server Component](/reference/rsc/use-client)
-1. the function passed to the `
`'s `action` prop be a [Server Action](/reference/rsc/use-server)
-1. the `useActionState` Hook be used to display the error message
+1. `
` dirender oleh [Server Component](/reference/rsc/use-client)
+1. fungsi yang diteruskan ke prop `action` `
` adalah [Server Action](/reference/rsc/use-server)
+1. Hook `useActionState` digunakan untuk menampilkan pesan kesalahan
-`useActionState` takes two parameters: a [Server Action](/reference/rsc/use-server) and an initial state. `useActionState` returns two values, a state variable and an action. The action returned by `useActionState` should be passed to the `action` prop of the form. The state variable returned by `useActionState` can be used to displayed an error message. The value returned by the [Server Action](/reference/rsc/use-server) passed to `useActionState` will be used to update the state variable.
+`useActionState` mengambil dua parameter: sebuah [Server Action](/reference/rsc/use-server) dan sebuah *state* awal. `useActionState` mengembalikan dua nilai, sebuah variabel *state* dan sebuah aksi. Aksi yang dikembalikan oleh `useActionState` harus diteruskan ke prop `action` dari formulir. Variabel *state* yang dikembalikan oleh `useActionState` dapat digunakan untuk menampilkan pesan kesalahan. Nilai yang dikembalikan oleh [Server Action](/reference/rsc/use-server) yang diteruskan ke `useActionState` akan digunakan untuk memperbarui variabel *state*.
@@ -340,7 +338,7 @@ export default function Page() {
const email = formData.get("email");
try {
await signUpNewUser(email);
- alert(`Added "${email}"`);
+ alert(`Menambahkan "${email}"`);
} catch (err) {
return err.toString();
}
@@ -348,12 +346,12 @@ export default function Page() {
const [message, signupAction] = useActionState(signup, null);
return (
<>
-
Signup for my newsletter
-
Signup with the same email twice to see an error
+
Daftar untuk newsletter saya
+
Daftar dengan email yang sama dua kali untuk melihat kesalahan
-
+
{!!message &&
{message}
}
>
@@ -366,7 +364,7 @@ let emails = [];
export async function signUpNewUser(newEmail) {
if (emails.includes(newEmail)) {
- throw new Error("This email address has already been added");
+ throw new Error("Alamat email ini sudah ditambahkan");
}
emails.push(newEmail);
}
@@ -386,13 +384,13 @@ export async function signUpNewUser(newEmail) {
-Learn more about updating state from a form action with the [`useActionState`](/reference/react/useActionState) docs
+Pelajari lebih lanjut tentang memperbarui *state* dari aksi formulir dengan dokumen [`useActionState`](/reference/react/useActionState).
-### Handling multiple submission types {/*handling-multiple-submission-types*/}
+### Menangani beberapa jenis pengiriman {/*handling-multiple-submission-types*/}
-Forms can be designed to handle multiple submission actions based on the button pressed by the user. Each button inside a form can be associated with a distinct action or behavior by setting the `formAction` prop.
+Formulir dapat dirancang untuk menangani beberapa aksi pengiriman berdasarkan tombol yang ditekan oleh pengguna. Setiap tombol di dalam formulir dapat dikaitkan dengan aksi atau perilaku yang berbeda dengan mengatur prop `formAction`.
-When a user taps a specific button, the form is submitted, and a corresponding action, defined by that button's attributes and action, is executed. For instance, a form might submit an article for review by default but have a separate button with `formAction` set to save the article as a draft.
+Ketika seorang pengguna mengetuk tombol tertentu, formulir disubmit, dan aksi yang sesuai, yang ditentukan oleh atribut dan aksi tombol tersebut, dieksekusi. Misalnya, sebuah formulir mungkin mengirimkan artikel untuk ditinjau secara default tetapi memiliki tombol terpisah dengan `formAction` diatur untuk menyimpan artikel sebagai draf.
@@ -401,20 +399,20 @@ export default function Search() {
function publish(formData) {
const content = formData.get("content");
const button = formData.get("button");
- alert(`'${content}' was published with the '${button}' button`);
+ alert(`'${content}' telah dipublikasikan dengan tombol '${button}'`);
}
function save(formData) {
const content = formData.get("content");
- alert(`Your draft of '${content}' has been saved!`);
+ alert(`Draf '${content}' Anda telah disimpan!`);
}
return (