I need to pass the refs from one component to a function passed in from another component as a prop, and I need to do it in typescript.
So the relevant code inside the child component is
class Login extends Component<IProps, IState> {
private emailRef = React.createRef<HTMLInputElement>();
private passRef = React.createRef<HTMLInputElement>();
constructor(props?) {
super(props);
}
login = () => {
const email = this.emailRef.current;
const pass = this.passRef.current;
this.props.login(email, pass);
}
which is ok, but now inside of my IProps I should declare login.
And I can't figure out how to do it?
As an example
interface IProps {
login: (u: any, p: any) => any,
errorMessage: ''
}
obviously those anys are no good, and need to be replaced with something better. How do I specify that I am in fact going to be passing a react ref here?
login: (u: HTMLInputElement, p: HTMLInputElement) => void