在React Final Form中,我们可以对format
类型的输入使用parse
或text
道具,以便存储与指定值不同的值,但这似乎不起作用复选框也是如此。
示例:
<FieldArray name='test' initialValue={[true, false]}>
<Field
component='input'
type='checkbox'
format={value => value ? 'foo' : null}
parse={value => value ? 'foo' : null}/>
</Field>
</FieldArray>
在此示例中,无论使用true
和false
,要存储的值仍为format
或parse
。可以将值从[true, false]
格式化为["foo"]
吗?
在此先感谢您的帮助。