react typescript functional component props code example
Example 1: react functional component typescript
import React from 'react';
interface Props {
}
export const App: React.FC<Props> = (props) => {
return (
<>
<SomeComponent/>
</>
);
};
Example 2: react typescript props
type CarProps = {
name: string;
brand: string;
price;
}
const Car: React.FC<CarProps> = (props) => {
const { name, brand, price } = props;
}
const Car: React.FC<CarProps> = ({ name, brand, price }) => {
}
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>
)
}
};