Is there a way to export a JavaScript React Class Component into a TypeScript file?
I have the following code:
Login.js
class Login extends Component {
constructor(props) {
super(props);
this.usernameText = React.createRef();
this.passwordText = React.createRef();
this.urlText = React.createRef();
this.keyPress = this.keyPress.bind(this);
}
.
.
.
}
export default Login;
index.ts
const Login = require("./uiManagement/jiraUI/Login/Login");
export {
Login as JiraUiLogin
}
In another project i did an npm import for the above to use the login component:
import { Component } from "react";
import { JiraUiLogin } from "infosysta-typescript-core";
class mLogin extends Component {
render() {
return (
<JiraUiLogin />
)
}
};
export default mLogin
But I'm having the following error:

What about changing the Login.js file to typescript?
import React, { Component } from "react";
interface Props {
}
interface State {
}
class Login extends Component<Props, State> {
usernameText = React.createRef<HTMLInputElement>();
passwordText = React.createRef<HTMLInputElement>();
urlText = React.createRef<HTMLInputElement>();
keyPress = (event: React.KeyboardEvent) => {
};
}
export default Login;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With