import React, { Component } from 'react';
type TypeProps={
title?:string
}
type typeState={
counter:number
focus:boolean
}
export default class App extends Component<TypeProps,typeState> {
constructor(props:TypeProps){
super(props)
this.state={
counter:0,
focus:false
}
this.myRef = React.createRef();
}
componentDidMount():void{
console.log(this.refs);
}
handlerPlusCounter=()=>{
this.setState(prevState=>{
return {counter:prevState.counter+1}
})
}
render() {
return (
<div>
<input type="text" ref={this.myRef} />
<h1>{this.state.counter} </h1>
<button onClick={this.handlerPlusCounter}>+</button>
<h3>{this.props.title} </h3>
</div>
)
}
}
Property 'myRef' does not exist on type 'App'.
Свойство "myRef" не существует в типе "App".