I'm having trouble with a React function component and defaulting a required prop.
Here's the component:
type Props = { message: string };
function Greeting({ message = "How are you?" }: Props) {
return <p>{message}</p>;
}
I should be able to consume it without passing the message prop:
<Greeting />
However, TypeScript raises a type error Property 'message' is missing in type '{}' but required in type 'Props':
Here's the issue in a CodeSandbox: https://codesandbox.io/s/still-microservice-lp7b5?fontsize=14&hidenavigation=1&theme=dark
I wasn't sure whether I am doing something wrong or whether this is a glitch in TypeScript? Any help would be appreciated.

Property 'message' is missing in type '{}' but required in type 'Props'.tsIt says you have required props type. Which is why typescript screams for this :) Just change type props like thismessage?:string.