server-act
Advanced tools
Comparing version 0.0.9 to 0.0.10
# server-act | ||
## 0.0.10 | ||
### Patch Changes | ||
- a2ab457: Fixed form action doc | ||
## 0.0.9 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "server-act", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"homepage": "https://github.com/chungweileong94/server-act#readme", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -104,11 +104,5 @@ # Server-Act | ||
if (formErrors) { | ||
return { | ||
success: false as const, | ||
formErrors: formErrors.formErrors.fieldErrors, | ||
}; | ||
return { formErrors: formErrors.formErrors.fieldErrors }; | ||
} | ||
return { | ||
success: true as const, | ||
message: `Hello, ${input.name}!`, | ||
}; | ||
return { message: `Hello, ${input.name}!` }; | ||
}); | ||
@@ -124,3 +118,3 @@ ``` | ||
export const ClientComponent = () => { | ||
const [state, dispatch] = useFormState(sayHelloAction); | ||
const [state, dispatch] = useFormState(sayHelloAction, { formErrors: {} }); | ||
@@ -130,7 +124,7 @@ return ( | ||
<input name="name" required /> | ||
{state?.formErrors?.name?.map((error) => <p key={error}>{error}</p>)} | ||
{state.formErrors?.name?.map((error) => <p key={error}>{error}</p>)} | ||
<button type="submit">Submit</button> | ||
{!!state?.success && <p>{state.message}</p>} | ||
{!!state.message && <p>{state.message}</p>} | ||
</form> | ||
@@ -137,0 +131,0 @@ ); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54811
131