【发布时间】:2020-05-05 22:59:12
【问题描述】:
我是 react native 的新手,我需要一些帮助。我正在尝试处理一个 TextInput ,用户可以在其中更新他们想要的任何文本值。例如,如果用户创建了一个名为“Bar”的文件夹,但后来用户决定更改“Bar1”的名称。怎么办???
到目前为止,这是我的代码:其中 value={prosp.children} 是文本值“Bar”。 onChangeText={(text) => handleText(text)},这里的文本暂时未定义,但稍后它将是我的文本更新“Bar1”或用户写的任何内容。
import React, { useState } from "react";
import { View, TextInput} from "react-native";
import styles from "../globalStyles/Styles";
const FolderList = (props) => {
const handleText = (value, text) => {};
return (
<View style={styles.homeRowFolder}>
<View style={styles.iconAndText}>
<TextInput
value={props.children}
onChangeText={(text) => handleText(text)}
style={styles.textdisplay}
></TextInput>
</View>
</View>
);
};
export default FolderList;
我也想使用反应钩子。 非常感谢您提前提供的帮助。欣赏。
【问题讨论】:
标签: javascript reactjs react-native react-hooks