基础 React Native + TypeScript + redux-forms

Basic React Native + TypeScript + redux-forms

我刚刚开始使用 React Native 和 TypeScript,我正在尝试向我的应用程序添加一个基本表单。我对此完全是菜鸟,所以请耐心等待。我可以让表格出现,但我不确定我需要在下面的代码中输入什么而不是问号才能正确输入检查:

import React from 'react'
import { Field, reduxForm } from 'redux-form'
import { Text, TextInput, View } from 'react-native'
import Styles from './Styles'

function renderInput(input: ?): TextInput {
  return <TextInput style={Styles.input} ? />
}

const MyForm = reduxForm({ form: 'my_form' })( props => {
  const { handleSubmit } = props
  return (
    <View>
      <Text>Bla</Text>
      <Field name="name" component={renderInput} type="text" />
      </View>  
  )
})

export default HopIngredientForm

如果有人能告诉我如何使用 TextInput(自定义组件?)来代替我自己的样式而无需定义单独的函数,那绝对是加分。

谢谢:)

如果我没听错,请将方法 renderInput 更改为:

function renderInput(input: string): JSX.Element {
  return <TextInput style={Styles.input}>{input}</TextInput>
}