问题描述
这里我使用 react hooks 设置初始状态和目标状态。在 from 组件中,我使用 Semantic UI React from 在输入中创建表单使用值,以设置一些已经通过表单输入的默认值。使用 onChange 编辑值但它不起作用。但 onChange 工作正常。
Parent Component
const ParentPane = (props) => {
const dispatch = usedispatch();
const [appName,setAppName] = useState([{ appName: props?.rowEditData?.appName }]);
const [pattern,setPattern] = useState("");
const [desc,setDesc] = useState("");
const [parentData,setParentData] = useState({
appName: "",pattern: "",desc: ""
});
Form Component
<Form size="large" inverted className="parentStyle">
<div>
<Form.Input
fluid
id="app"
name="appName"
label="Application Name"
value={props?.rowEditData.appName}
onChange={(event) => setAppName(event.target.value)}
/>
<Form.Input
fluid
id="path"
name="pattern"
label="Request Path"
placeholder="eg: /home"
value={props?.rowEditData.pattern}
onChange={(event) => setPattern(event.target.value)}
/>
<Form.Input
fluid
path="des"
name="desc"
label="Description"
value={props?.rowEditData.description}
onChange={(event) => setDesc(event.target.value)}
/>
<Button
className="submitButton"
onClick={(event) => saveOrUpdateMock(event,"UPDATE")}
style={style.labelStyle}
>
Save
</Button>
</div>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)