我想添加每个对象的位置坐标,以便我可以将其指定为放置区。
我可以将一段数据输入objLocation
,但很明显,它会在每个SubComponent
呈现时保持覆盖。构建该对象位置数组的正确方法是什么?
const data = [
{ id: 1 },
{ id: 2 },
{ id: 3 },
]
export default class Viewport extends Component {
this.state = {
objLocation = [],
}
render() {
return (
{data.map( d => {
return(
<SubComponent onLayout={this.getLayout} id={d.id} />
)
})}
)
}
getLayout = (e) => (
const obj = {
width: e.nativeEvent.layout.width,
height: e.nativeEvent.layout.height,
x: e.nativeEvent.layout.x,
y: e.nativeEvent.layout.y,
}
this.setState({
objLocation: obj
});
}
}
答案 0 :(得分:0)
找到答案here。
SystemOut O 13:18:00,012 |-INFO in ch.qos.logback.classic.net.SMTPAppender[email] - SMTPAppender [email] is tracking [1] buffers