From 91108a4c5cba711e4e3d70d503c5d14038da5ffc Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Mon, 22 Jan 2018 14:20:10 -0600 Subject: [PATCH 1/2] [typescript] show mutator example - undefined mutators are difficult --- src/ReactFinalForm.d.test.tsx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/ReactFinalForm.d.test.tsx b/src/ReactFinalForm.d.test.tsx index 66524c83..bed68f93 100644 --- a/src/ReactFinalForm.d.test.tsx +++ b/src/ReactFinalForm.d.test.tsx @@ -1,5 +1,6 @@ import * as React from 'react' import { Form, Field } from './index' +import { Mutator } from 'final-form/dist' const onSubmit = async (values: any) => { console.log(values) @@ -63,3 +64,36 @@ const simpleSubscription = () => ( )} ) + +const setValue: Mutator = ([name, newValue], state, { changeValue }) => { + changeValue(state, name, value => newValue) +} + +const mutated = () => ( +
+ {({ + handleSubmit, + mutators: { setValue }, + submitting, + pristine, + values + }) => ( + + + +
{JSON.stringify(values)}
+ + )} + +) From 198652e34906a049f019a23bab0c0feb0d6f37d6 Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Mon, 22 Jan 2018 14:41:01 -0600 Subject: [PATCH 2/2] Fixed and tested with https://github.com/final-form/final-form/pull/68 --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index 73142efc..e3b7a3d2 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -44,7 +44,7 @@ export interface SubsetFormApi { change: (name: string, value: any) => void focus: (name: string) => void initialize: (values: object) => void - mutators?: { [key: string]: Function } + mutators: { [key: string]: Function } reset: () => void }