I need the reference of the component. Just shifted from jsx to tsx and can't find a solution for this problem.
Other workaround would be to use query selector but that's not a good way of doing things in react I believe.
Here is the constructor function
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);
}
Looks like you have an out of date version of @types/react
. The latest version 16.3.14
has type definitions for createRef
.
In my Typescript codebase I had to update react-dom types:
yarn upgrade @types/react-dom^16.3.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With