【发布时间】:2018-10-25 03:29:02
【问题描述】:
我需要组件的引用。刚从 jsx 转移到 tsx,找不到解决这个问题的方法。
其他解决方法是使用查询选择器,但我相信这不是一种很好的反应方式。
这里是构造函数
constructor(props) {
super(props);
this.state = {
data: initialData,
showNewListForm: false,
whichButtonClicked: undefined,
background: props.background || "#23719f"
};
this.divContainerRef = React.createRef();
console.log("kanban reference : " + React.createRef().current);
this.handleDragStart = this.handleDragStart.bind(this);
this.handleDragEnd = this.handleDragEnd.bind(this);
this.handleLaneDragEnd = this.handleLaneDragEnd.bind(this);
this.handleLaneDragStart = this.handleLaneDragStart.bind(this);
this.onCardAdd = this.onCardAdd.bind(this);
this.onCardClick = this.onCardClick.bind(this);
this.addNewListHandler = this.addNewListHandler.bind(this);
this.containerRefResolver = this.containerRefResolver.bind(this);
this.isBoardPresent = this.isBoardPresent.bind(this);
}
【问题讨论】:
-
您是否正确导入了
React? -
import * as React from 'react';
标签: javascript reactjs typescript jsx tsx