渲染反应组件存储在包含对象数组的状态
当我在桌子上应用过滤器时,我想更改过滤器图标的图标颜色,但是图标颜色并没有以某种方式更改。
这是我的组件,
const Table = () => {
const [tableFilters, setTableFilters = useState({name: []})
let tableColumns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
filters: [],
filterDropdownVisible: false,
filterIcon: (filtered: boolean) => {
return (
<TableFilterIcon filterColumnData={filters.name.data} />
)
},
},
]
const [columns, setColumns] = useState(tableColumns)
return (
<>
<CommonTable
data={data}
columns={tableColumns}
/>
</>
)
}
export default Table
在TableFiltericon组件中,我正在基于所选过滤器呈现非彩色和彩色图标,如果使用过滤器,则我正在显示颜色图标。 但是,当我应用过滤器时,TableFiltericon组件并没有呈现,这就是图标颜色不变的原因。也许TableFiltericon组件是列的对象,这就是为什么?
注意:如果我不将列存储在状态中,而直接将列传递到可插件的组件,则可以使用。
谁能帮我吗?另外,我正在为UI组件使用ANT设计框架。
When I apply the filters on the table I want to change the Icon color of the filter Icon, but the icon color is not changing somehow.
This is my component,
const Table = () => {
const [tableFilters, setTableFilters = useState({name: []})
let tableColumns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
filters: [],
filterDropdownVisible: false,
filterIcon: (filtered: boolean) => {
return (
<TableFilterIcon filterColumnData={filters.name.data} />
)
},
},
]
const [columns, setColumns] = useState(tableColumns)
return (
<>
<CommonTable
data={data}
columns={tableColumns}
/>
</>
)
}
export default Table
In TableFilterIcon component I am rendering non-colored and colored icon based on the selected filters, if filters are applied then I am showing color icon.
But the TableFilterIcon component is not rendering when I apply the filters that's why Icon color is not changing. Maybe the TableFilterIcon component is in the object of columns that's why ??
Note: if I don't store the columns in state and directly pass the columns to the CommonTable component then it works.
Can anyone help me with this ?? Also, I am using Ant Design Framework for UI components.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论