Goal:
Show the value of the element id ttt in console when you press the button "showvalue"
Problem:
The code won't work what part of the code am I missing?
Stackblitz:
https://stackblitz.com/edit/react-ts-sgczgk?
Info:
Newbie in React TS
Thank you!
import React, { Component } from 'react';
import { render } from 'react-dom';
import './style.css';
interface AppProps {}
interface AppState {
name: string;
}
class App extends Component<AppProps, AppState> {
constructor(props) {
super(props);
this.textInput = React.createRef();
this.focusTextInput = this.focusTextInput.bind(this);
}
public textInput;
focusTextInput() {
console.log(this.textInput.value);
}
render() {
return (
<div>
<input id="ttt" type="text" ref={this.textInput} />
<input type="button" value="showvalue" onClick={this.focusTextInput} />
</div>
);
}
}
render(<App />, document.getElementById('root'));