mirror of
https://github.com/LukeHagar/form.git
synced 2025-12-06 04:19:43 +00:00
fix: onSubmit should now behave as expected
* fix: memoize all non-function form props by default * chore: migrate useStableFormOpts to useMemo * fix: options passed to useField will not always cause a re-render * chore: minor code cleanups * test: add previously failing test to demonstrate fix * chore: fix linting * fix: running form.update repeatedly should not wipe form state * test: add test to validate formapi update behavior * test: add initial tests for useStableOptions * chore: remove useStableOpts and useFormCallback
This commit is contained in:
@@ -17,13 +17,10 @@ function FieldInfo({ field }: { field: FieldApi<any, any> }) {
|
||||
export default function App() {
|
||||
const form = useForm({
|
||||
// Memoize your default values to prevent re-renders
|
||||
defaultValues: React.useMemo(
|
||||
() => ({
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
}),
|
||||
[],
|
||||
),
|
||||
defaultValues: {
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
},
|
||||
onSubmit: async (values) => {
|
||||
// Do something with form data
|
||||
console.log(values);
|
||||
|
||||
Reference in New Issue
Block a user