1
1
mirror of https://github.com/theoludwig/react-component-form.git synced 2024-07-17 07:30:13 +02:00

chore(example): fix translation with global message

This commit is contained in:
Divlo 2022-08-26 22:53:59 +02:00
parent 52081972e9
commit c979bab553
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
3 changed files with 11 additions and 6 deletions

View File

@ -7,7 +7,7 @@ import { useFormTranslation } from '../hooks/useFormTranslation'
import { userSchema } from '../models/User'
import { FormState } from './design/FormState'
const wait = async (ms: number): Promise<void> => {
const simulateServerRequest = async (ms: number): Promise<void> => {
return await new Promise((resolve) => {
setTimeout(resolve, ms)
})
@ -22,12 +22,12 @@ export const FormExample: React.FC = () => {
formData,
formElement
) => {
await wait(4000)
await simulateServerRequest(4000)
console.log('onSubmit:', formData)
formElement.reset()
return {
type: 'success',
message: t('common:success')
value: 'common:success-message'
}
}
@ -58,7 +58,12 @@ export const FormExample: React.FC = () => {
Submit
</Button>
</Form>
<FormState id='message' state={fetchState} message={message} />
<FormState
id='message'
state={fetchState}
message={message != null ? t(message) : undefined}
/>
</section>
)
}

View File

@ -1,5 +1,5 @@
{
"about": "This is an example of using <0>`react-component-form`</0> inside a Next.js application. The application shows how to use the <0>`{`<Form />`}`</0> component with the <0>`useForm`</0> hook to validate and submit a form with a <0>`name`</0> and an <0>`email`</0> input.",
"about": "This is an example of using <0>`react-component-form`</0> inside a Next.js application. The application shows how to use the <0>`<Form />`</0> component with the <0>`useForm`</0> hook to validate and submit a form with a <0>`name`</0> and an <0>`email`</0> input.",
"name": "Name",
"error": "Error",
"success": "Success",

View File

@ -1,5 +1,5 @@
{
"about": "Ceci est un exemple d'utilisation de <0>`react-component-form`</0> dans une application Next.js. L'application montre comment utiliser le composant <0>`{`<Form />`}`</0> avec le hook <0>`useForm`</0> hook pour valider et soumettre un formulaire avec un input `name` et `email`.",
"about": "Ceci est un exemple d'utilisation de <0>`react-component-form`</0> dans une application Next.js. L'application montre comment utiliser le composant <0>`<Form />`</0> avec le hook <0>`useForm`</0> hook pour valider et soumettre un formulaire avec un input `name` et `email`.",
"name": "Nom",
"error": "Erreur",
"success": "Succès",