import React, { useState } from 'react'; // Define the types for the props interface MyComponentProps { title: string; subtitle?: string; // Optional prop } const MyComponent: React.FC = ({ title, subtitle }) => { // Define a state variable with an initial value const [count, setCount] = useState(0); // Function to handle button click const handleButtonClick = () => { setCount(count + 1); }; return (

{title}

{subtitle &&

{subtitle}

}

Current count: {count}

); }; export default MyComponent;