We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://react-21qt77.stackblitz.io/
import { Table, Badge, Menu, Dropdown, Input, Form, Select } from "antd"; import { useState } from "react";
const { Option } = Select; export default () => { const [value, setValue] = useState(""); const expandedRowRender = () => { const handleChange = (e) => { setValue(e); }; return ( <> <Select style={{ width: 120 }} onChange={handleChange}> Jack Lucy Disabled yiminghe </> ); };
const columns = [ { title: "Name", dataIndex: "name", key: "name" }, { title: "Platform", dataIndex: "platform", key: "platform" }, { title: "Version", dataIndex: "version", key: "version" }, { title: "Upgraded", dataIndex: "upgradeNum", key: "upgradeNum" }, { title: "Creator", dataIndex: "creator", key: "creator" }, { title: "Date", dataIndex: "createdAt", key: "createdAt" }, { title: "Action", key: "operation", render: () => Publish }, ];
const data = []; for (let i = 0; i < 3; i) { data.push({ key: i, name: "Screem", platform: "iOS", version: "10.3.4.5654", upgradeNum: 500, creator: "Jack", createdAt: "2014-12-24 23:12:00", }); }
return ( <Table rowKey='key' className="components-table-demo-nested" columns={columns} expandable={{ expandedRowRender: expandedRowRender, }} dataSource={data} /> ); };
demo是一个简化版的需求,expandedRowRender返回的是一个表单,默认全部展开的情况下,当我对相应表单进行form.setFieldValue操作的时候,只是修改当前行的数据。而不影响其他的行的表单数据
demo是一个简化版的需求,expandedRowRender返回的是一个表单,默认全部展开的情况下,当我对相应表单进行form.setFieldValue操作的时候,假如有两行,我修改第一行或者第二行的表单值的时候,都会映射到第三行的表单去,也就是说对表单进行赋值的时候,总是会对最后一个表单赋值。
The text was updated successfully, but these errors were encountered:
实际场景如下:父组件: 子组件:
Sorry, something went wrong.
这样写相当于三个 Select 共用了一份 value 状态,肯定是一改都改了。你需要把状态隔离到各个子组件中。
No branches or pull requests
Reproduction link
https://react-21qt77.stackblitz.io/
Steps to reproduce
import { Table, Badge, Menu, Dropdown, Input, Form, Select } from "antd";
import { useState } from "react";
const { Option } = Select;
export default () => {
const [value, setValue] = useState("");
const expandedRowRender = () => {
const handleChange = (e) => {
setValue(e);
};
return (
<>
<Select style={{ width: 120 }} onChange={handleChange}>
Jack
Lucy
Disabled
yiminghe
</>
);
};
const columns = [
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Platform", dataIndex: "platform", key: "platform" },
{ title: "Version", dataIndex: "version", key: "version" },
{ title: "Upgraded", dataIndex: "upgradeNum", key: "upgradeNum" },
{ title: "Creator", dataIndex: "creator", key: "creator" },
{ title: "Date", dataIndex: "createdAt", key: "createdAt" },
{ title: "Action", key: "operation", render: () => Publish },
];
const data = [];
for (let i = 0; i < 3; i) {
data.push({
key: i,
name: "Screem",
platform: "iOS",
version: "10.3.4.5654",
upgradeNum: 500,
creator: "Jack",
createdAt: "2014-12-24 23:12:00",
});
}
return (
<Table
rowKey='key'
className="components-table-demo-nested"
columns={columns}
expandable={{
expandedRowRender: expandedRowRender,
}}
dataSource={data}
/>
);
};
What is expected?
demo是一个简化版的需求,expandedRowRender返回的是一个表单,默认全部展开的情况下,当我对相应表单进行form.setFieldValue操作的时候,只是修改当前行的数据。而不影响其他的行的表单数据
What is actually happening?
demo是一个简化版的需求,expandedRowRender返回的是一个表单,默认全部展开的情况下,当我对相应表单进行form.setFieldValue操作的时候,假如有两行,我修改第一行或者第二行的表单值的时候,都会映射到第三行的表单去,也就是说对表单进行赋值的时候,总是会对最后一个表单赋值。
The text was updated successfully, but these errors were encountered: