道具类型失败:类型为“数字”的无效道具“值”
Failed prop type: Invalid prop `value` of type `number`
我在 React Native 中遇到 TextInput 问题,所以当我提交更新时,我收到错误消息“提供给 ForwardRef(TextInput) 的类型编号的无效道具值”。谁能帮我解决这个问题。
错误:
Warning: Failed prop type: Invalid prop value
of type number
supplied to ForwardRef(TextInput)
, expected string
. at
node_modules\react-native\Libraries\LogBox\LogBox.js:173:8 in
registerError
这是我的代码:
const [Phase, setPhase] = useState('')
const [Days, setDay] = useState(null)
const [TempMin, setTempMin] = useState(null)
<TextInput
style={styles.input}
onChangeText={(text) => setPhase(text)}
placeholder={plants.Phase}
value={Phase}
name="Phase"
selectTextOnFocus={false}
editable={false}
/>
<Text style={styles.titleInput}>Nombre de jour</Text>
<TextInput
style={styles.input}
onChangeText={(text) => setDay(text)}
keyboardType='numeric'
placeholder={`${plants.Days}`}
value={Days}
name="Days"
/>
<Text style={styles.titleInput}>T° Min</Text>
<TextInput
style={styles.input}
onChangeText={(text) => setTempMin(text)}
keyboardType='numeric'
placeholder={`${plants.TempMin}`}
value={TempMin}
name="TempMin"
/>
value={String(Days)}
或
if(String(Days)){....}
我在 React Native 中遇到 TextInput 问题,所以当我提交更新时,我收到错误消息“提供给 ForwardRef(TextInput) 的类型编号的无效道具值”。谁能帮我解决这个问题。
错误:
Warning: Failed prop type: Invalid prop
value
of typenumber
supplied toForwardRef(TextInput)
, expectedstring
. at node_modules\react-native\Libraries\LogBox\LogBox.js:173:8 in registerError
这是我的代码:
const [Phase, setPhase] = useState('')
const [Days, setDay] = useState(null)
const [TempMin, setTempMin] = useState(null)
<TextInput
style={styles.input}
onChangeText={(text) => setPhase(text)}
placeholder={plants.Phase}
value={Phase}
name="Phase"
selectTextOnFocus={false}
editable={false}
/>
<Text style={styles.titleInput}>Nombre de jour</Text>
<TextInput
style={styles.input}
onChangeText={(text) => setDay(text)}
keyboardType='numeric'
placeholder={`${plants.Days}`}
value={Days}
name="Days"
/>
<Text style={styles.titleInput}>T° Min</Text>
<TextInput
style={styles.input}
onChangeText={(text) => setTempMin(text)}
keyboardType='numeric'
placeholder={`${plants.TempMin}`}
value={TempMin}
name="TempMin"
/>
value={String(Days)}
或
if(String(Days)){....}