I have an existing React component that's coded in JSX and I can't convert to Typescript at this time. I'd like to make use of it in a new React application that is being written in Typescript. I cannot figure out if it's possible to import and use the JSX code within the TSX code. Is this possible? How do I do it?
Thanks
The example below gives the error: TS2604:JSX element type 'OldCode' does not have any construct or call signatures.
OldCode.jsx
import React from 'react'
export default React.createClass({
render() {
return <div>OldCode</div>
}
})
NewCode.tsx
import * as React from 'react';
import { OldCode } from './OldCode';
export default class NewCode extends React.Component<any, any> {
render() {
return (
<OldCode/>
);
}
}
const NewCode = require('./NewCode').default;
– cwtuan