【发布时间】:2020-06-07 20:47:40
【问题描述】:
在我的反应项目中,我正在使用 Formik 库。对于输入,我正在使用 TextInputMask 这是其他库。
export default function Calc() {
return (
<Formik
initialValues={{ monthly_rental: '', }}
>
{(props) => (
<View>
<Text>Monthly rental</Text>
<TextInputMask
type={"money"}
options={{
precision: 0,
separator: ".",
delimiter: ",",
unit: "£",
suffixUnit: ""
}}
placeholder={"£500"}
value={props.values.monthly_rental}
includeRawValueInChangeText={true}
onChangeText={props.handleChange('monthly_rental')}
/>
</View>
)}
</Formik>
)
}
上面的代码运行良好,但我想要的是在onChangeText={props.handleChange('monthly_rental')} 上设置原始值而不是格式化值。
我已经看到了这段代码,但我现在不去实现它
onChangeText={(text, rawValue) => {
this.setState({
value: text,
raw: rawValue
})
【问题讨论】:
标签: react-native formik textinput