const getRefElement = <T>( element?: RefObject<Element> | T, ): Element | T | undefined | null => { if (element && 'current' in element) { return element.current; } return element; }; code example
Example: Cannot find name 'RefObject'
class TestApp extends React.Component<AppProps, AppState> {
private stepInput: React.RefObject<HTMLInputElement>;
constructor(props) {
super(props);
this.stepInput = React.createRef();
}
render() {
return <input type="text" ref={this.stepInput} />;
}
}