react-nativeでredux-formを使用しようとしていましたが、最も単純なフォームが動作しません。reactxネイティブ0.32.0で動作するredux-form 6.0.2を取得できません
私は2つの問題を抱えて:
私はTextInputコンポーネントにprops.inputをバインドする場合は、すべてのキー入力が食べられますし。あなたは入力された文字を一瞬見て、それは消えます。 試行錯誤の結果、props.input.valueをバインドしないと、入力した文字がフィールドに表示されることが判明しました。
私のサブミット機能は、常に空の値の引数を渡されます。
// @flow
import React, { PropTypes } from 'react'
import {
StyleSheet,
Text,
TextInput,
TouchableHighlight,
View,
} from 'react-native'
import { reduxForm, Field } from 'redux-form'
const styles = StyleSheet.create({
form: {
flex: 1,
flexDirection: 'column',
paddingLeft: 16,
paddingRight: 16,
},
submitbutton: {
height: 48,
marginTop: 32,
},
textfield: {
height: 28,
},
});
class TextInputField extends React.Component {
render() {
const { input, placeholder, style, input: { onChange } } = this.props
console.log(this.props)
return (
<TextInput
onChange={onChange}
placeholder={placeholder}
style={style}
/>
)
}
}
class SigninScene extends React.Component {
render() {
const { handleSubmit, submitting } = this.props
return (
<View style={styles.form}>
<Field name="email" component={TextInputField} placeholder="email" style={styles.textfield}/>
<Field name="password" component={TextInputField} placeholder="password" style={styles.textfield}/>
<TouchableHighlight
onPress={handleSubmit((values, dispatch, props) => {
console.log("handling submit")
console.log(values)
})}
>
<Text style={styles.submitbutton}>Signin</Text>
</TouchableHighlight>
</View>
)
}
}
export default reduxForm({ form: 'signin' })(SigninScene)
を依頼することを躊躇しないで、あなたはImmutable.jsを使用していますか?私は誤って 'redux-form/immutable'の代わりに' redux-form'から 'Field'をインポートしたときにこの動作を見ました – sfridman
うわー!それでおしまい!私はpackage.jsonに追加していたことを忘れていました。インポートを変更するとすぐに、完全に動作します。ありがとうございました! –
これらの危険な隠れた仮定-_- – sfridman