tsx react component code example
Example 1: React with Typescript
npx create-react-app yourProjectName --template typescript
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
Example 2: react tsx component example
import React from 'react';
interface Props {
}
const App: React.FC<Props> = (props) => {
return (
<div><div/>
);
};
export default App;
Example 3: TYPESCript props class component
class Test extends Component<PropsType,StateType> {
constructor(props : PropsType){
super(props)
}
render(){
console.log(this.props)
return (
<p>this.props.whatever</p>
)
}
};