DEV Community

Discussion on: React with TypeScript: Optional Props with Default Values

Collapse
 
olivertembo profile image
olivertembo

What about this?
interface Props{
name: string;
middleName?: string;
}

const MyName = ({
name = John,
middleName = "",
}: Props) => {

What is wrong with the optional parameter?

Collapse
 
thesameeric profile image
Eric O Okiti

Personally, I feel this is recommended aproach nowadays since support for defaultProps is deprecated.