我是React的新手,到目前为止,我看过的所有示例代码都显示了constructor(props)。我正在尝试传递数据({data:{action:[action: "changed", timestamp: 12345678], ...}
,但我感到困惑,因为我之前从未见过使用构造函数的语法。
class Graph extends Component {
constructor({nodes}) {
const times = d3.extent(nodes.action.map(action => {action.action}))
const range = [50, 450]
super({nodes})
this.state = {nodes, times, range}
}