发布于 2016-06-06 18:42:50
您可以尝试这样做,生成id并使用该id作为键,而我认为React DOM会根据键呈现元素:
constructor(props) {
super(props);
this.id = 0; // add id
....
}
addShape(e) {
...
updatedShapes.push({
x: e.clientX,
y: e.clientY,
id: this.id++
});
...
}
randomShape(shape)
{
...
<circle ... key={shape.id} .../>;
...
}https://stackoverflow.com/questions/37653677
复制相似问题