【发布时间】:2019-04-02 22:15:27
【问题描述】:
我是 redux 表单的新手。我尝试利用它为我用 Typescript 编写的 react 本机应用程序中的一个文本输入字段提供的好处,实际上只是一个文本输入字段。
<Field name="payoutInput" type="text" component={this.renderPayout}/>
private renderPayout = (field: any) => (
<View style={{flexDirection: "row", flex: 0.22, justifyContent: "flex-end"}}>
<Text style={{fontSize: 17}}>
$
</Text>
<TextInput style={{fontSize: 17}} defaultValue={String(this.props.balance)} autoFocus={true} keyboardType={'number-pad'} onEndEditing={this.calculatePayout}/>
</View>
)
我注意到当我在 reactotron 中监控状态时,我实际上看不到表单状态中的值。使用formValueSelector 也会给我undefined。所以我想知道是否有必要将Field 包装在一个表单中?
很高兴根据请求提供更多上下文。
【问题讨论】:
-
如果是这种情况,我应该用什么将
Field包装在打字稿中?
标签: react-native redux react-redux redux-form