Reactjs 道具更改后,React组件不会重新渲染
更新道具时,使用Ant Design Framework的React组件不会重新渲染。数据显示在控制台中已更新,但在列表标记中未更新。 这是我代码的一部分Reactjs 道具更改后,React组件不会重新渲染,reactjs,react-redux,antd,Reactjs,React Redux,Antd,更新道具时,使用Ant Design Framework的React组件不会重新渲染。数据显示在控制台中已更新,但在列表标记中未更新。 这是我代码的一部分 render() { const props = this.props; data=[ { 'title':'name1', 'content':props.data.content1 }, { 'title':'name2', 'content':p
render() {
const props = this.props;
data=[
{
'title':'name1',
'content':props.data.content1
},
{
'title':'name2',
'content':props.data.content2
},
]
console.log("Data..",data);
return (
<Page {...props}>
<Helmet title="Organizations" />
<div className="card">
<div className="card-header">
<div className="utils__title">
<strong>Organization Details</strong>
</div>
</div>
<div className="card-body" span={20}>
<div className="organization">
<div className="organization_details">
<List
grid={{ gutter: 16, column: 1 }}
dataSource={data}
size="small"
renderItem={item => (
<List.Item>
<Card className="list1" title={item.title} bordered={false}>
{item.content}
</Card>
</List.Item>
)}
/>
</div>
</div>
</div>
</div>
</Page>
)
render(){
const props=this.props;
资料=[
{
“标题”:“名称1”,
“内容”:props.data.content1
},
{
“标题”:“名称2”,
“内容”:props.data.content2
},
]
console.log(“数据..”,数据);
返回(
组织详细信息
(
{item.content}
)}
/>
)
}我认为数据这里不是您想要使用的数据变量 使用const就可以了
// Destructure your props like this
const { props } = this;
const data=[
{
'title':'name1',
'content':props.data.content1
},
{
'title':'name2',
'content':props.data.content2
},
]
我认为数据这里不是您想要使用的数据变量 使用const就可以了
// Destructure your props like this
const { props } = this;
const data=[
{
'title':'name1',
'content':props.data.content1
},
{
'title':'name2',
'content':props.data.content2
},
]
如何将道具传递给上面组件的渲染函数?将道具传递给此组件时,请使用标记的键属性。如何将道具传递给上面组件的渲染函数?将道具传递给此组件时,请使用标记的键属性