typescript react type is react component code example
Example 1: typescript react class component
import * as React from 'react';
export interface TestProps {
count: number;
}
export interface TestState {
count: number;
}
class Test extends React.Component {
state = { count:0 }
render() {
return ( this is test
);
}
}
export default Test;
Example 2: ts react props type
type Props = {
size: string;
}
const Component = ({ size = 'medium' }: Props) => (
);