Typescript use in React2019-08-20Θ
Refs#
class App extends React.Component<AppProps, AppState> {private InputRef = React.RefObject<HTMLInputElement>;constructor(props) {super(props);this.InputRef = React.createRef();}render() {return <input type="text" ref={this.InputRef} />;}}
Hooks#
const App = (props: AppProps) => {const InputRef = React.useRef<HTMLDivElement>(null);return <input type="text" ref={this.InputRef} />;}