Here's a similar question with an answer: React with TypeScript - define defaultProps in stateless function

import React, { Component } from 'react';
import { Text } from 'react-native';

interface TestProps {
    title?: string,
    name?: string
}

const defaultProps: TestProps = {
    title: 'Mr',
    name: 'McGee'
}

const Test: React.SFC<TestProps> = (props) => (
    <Text>
        {props.title} {props.name}
    </Text>
);

Test.defaultProps = defaultProps;

export default Test;
Answer from Matt Stow on Stack Overflow
🌐
DEV Community
dev.to › fullstackchris › react-with-typescript-optional-props-with-default-values-33nc
React with TypeScript: Optional Props with Default Values - DEV Community
October 10, 2021 - import * as React from "react"; // Required props interface IFancyTitleRequiredProps { title: string; } // Optional props interface IFancyTitleOptionalProps { color: string; fontSize: number; } // Combine required and optional props to build the full prop interface interface IFancyTitleProps extends IFancyTitleRequiredProps, IFancyTitleOptionalProps {} // Use the optional prop interface to define the default props const defaultProps: IFancyTitleOptionalProps = { color: "red", fontSize: 40, }; // Use the full props within the actual component const FancyTitle = (props: IFancyTitleProps) => { co
Discussions

How to pass optional elements to a component as a prop in reactjs
One thing you can do is have default props (usually initialised to a no-op) for your component. For example, if you want to have an optional function prop: class NewComponent extends React.Component { ... More on stackoverflow.com
🌐 stackoverflow.com
Default props not working in functional component
Expected behavior: According to ... in Component. Actual behavior: The following compile error is thrown: Property 'optional' is missing in type '{ name: string; }' but required in type 'Props'. Playground Link: Link It doesn't look like the playground supports TSX. ... 👍React with ... More on github.com
🌐 github.com
20
May 4, 2019
Should we use React.FC to provide type for Components?
I feel like the momentum is moving away from it, but it's still common to see it in use in tutorials and blog posts etc., so it's not definitely wrong. But I prefer to leave it out. More on reddit.com
🌐 r/reactjs
36
46
August 27, 2023
Pass function with parameters as prop
If: You’re passing a value to a component as a prop You’re passing a function to the same component as another prop The first value is only used to pass into the function Then you should probably remove the first prop and make the parent handle the value. Instead of this: Do this: handleEvent(foo)} /> The Child component doesn’t actually care about value, so it’s better to remove the prop altogether. More on reddit.com
🌐 r/reactjs
6
2
November 8, 2022
🌐
Pluralsight
pluralsight.com › what makes pluralsight different | pluralsight › tech guides & tutorials
Defining Props in React Function Component with Typescript | Pluralsight
Or you just want to have cleaner syntax within your component? For those cases, you can leverage a JavaScript syntax feature known as destructuring. This allows more flexibility in how you can define your props. // Using the same FullName interface from the last example function FunctionalComponent({firstName, lastName}:FullName){ // firstName // lastName } What if you wanted to add a middle name? Not everyone has a middle name, so you want to make it optional.
🌐
DEV Community
dev.to › lico › i-ruined-my-react-components-by-using-optional-props-3o64
I ruined my React components by using optional props - DEV Community
December 22, 2022 - There were too many options and I wasn't sure what I was going to use to make the component work properly. I also used unexpected default values a lot. It makes plenty of unnecessary defensive code and I couldn't expect what default values it has. I will show you some examples that are similar to the mistakes that I made. Let's say, there is a Button component like below. import { ReactNode } from 'react'; type ButtonType = 'primary' | 'secondary'; interface ButtonProps { children?: ReactNode | string; onClick?: VoidFunction; type?: ButtonType; } const Button = ({ children, onClick, type = 'primary' }: ButtonProps) => { const bgColor = type === 'primary' ?
🌐
LogRocket
blog.logrocket.com › home › a complete guide to react default props
A complete guide to React default props - LogRocket Blog
June 4, 2024 - Optional props are not mandatory and are useful when certain props are not essential for the component to function. Our HeaderParent component, as defined here, passes an optional prop, version to its child component ReactHeader:
🌐
DhiWise
dhiwise.com › post › how-react-optional-props-can-improve-the-maintainability
Embracing Optional Props for Robust React Applications
June 14, 2024 - Optional props in React are properties that a component can receive but are not required for the component to function correctly. By segregating required and optional props into two interfaces, you can clearly define which props are essential ...
🌐
Steve Kinney
stevekinney.com › courses › react with typescript › complete guide to react component props with typescript
Complete Guide to React Component Props with TypeScript | React with TypeScript | Steve Kinney
March 17, 2026 - interface ButtonProps { // Required props - must be provided children: React.ReactNode; onClick: () => void; // Optional props - can be omitted variant?: 'primary' | 'secondary' | 'danger'; disabled?: boolean; size?: 'small' | 'medium' | 'large'; } // ✅ Good - required props are provided <Button onClick={() => alert('clicked')}> Click me </Button> // ❌ Bad - TypeScript error: missing required 'onClick' <Button> Click me </Button> The rule of thumb: make props required when the component genuinely can’t function without them.
Find elsewhere
🌐
DEV Community
dev.to › bytebodger › default-props-in-react-typescript-2o5o
Default Props in React/TypeScript - DEV Community
July 29, 2020 - While the above code indeed "works" just fine, I found that things started to get wonky when I began adding functions inside the functional component. Consider this example: interface Props extends PropsWithChildren<any>{ requiredString: string, requiredNumber: number, optionalBoolean?: boolean, optionalString?: string, optionalNumber?: number, } export default function MyTSComponent(props: Props) { props = cloneObject(props); props.optionalBoolean = props.optionalBoolean !== undefined ?
🌐
Bobby Hadz
bobbyhadz.com › blog › react-optional-props-typescript
Set optional props with default values in React TypeScript | bobbyhadz
Copied!interface EmployeeProps ... <Employee /> </div> ); } ... All of the properties in the EmployeeProps type are marked as optional, so the component can be used without being provided props....
🌐
Meje
meje.dev › blog › optional-props-in-typescript
Optional props in TypeScript
April 24, 2023 - Since all other props in the component's interface are optional, the default path will always be "/icons/${name}.svg"
🌐
React TypeScript Cheatsheets
react-typescript-cheatsheet.netlify.app › typing defaultprops
Typing defaultProps | React TypeScript Cheatsheets
type GreetProps = typeof Greet.defaultProps & { age: number; }; class Greet extends React.Component<GreetProps> { static defaultProps = { age: 21, }; /*...*/ } // Type-checks! No type assertions needed! let el = <Greet age={3} />; React.JSX.LibraryManagedAttributes nuance for library authors · The above implementations work fine for App creators, but sometimes you want to be able to export GreetProps so that others can consume it. The problem here is that the way GreetProps is defined, age is a required prop when it isn't because of defaultProps.
🌐
Delft Stack
delftstack.com › home › howto › typescript › typescript optional props in react
How to Use Optional Props With Default Values in React | Delft Stack
February 2, 2024 - The default values can be directly assigned and used while rendering the component. interface Props { color? : string; size: number; title? : string; } const defaultProps : Props = { color :"red", size : 20, title : "A cool title" } function Card(props : Props){ return ( <div> <div>{props.color}</div> <div>{props.size}</div> <div>{props.title}</div> </div> ) } Card.defaultProps = defaultProps; function App() { return ( <div> <Card size={20} title="Cool card" /> </div> ) }
🌐
Levelup
levelup.video › tutorials › react-and-typescript-for-everyone › default-and-optional-props
React & TypeScript For Everyone
Now that we have our prop types setup, we will take a look at default and optional props. By using the default and optional props, we can further ensure that our React components will receive the exact type of props that we expect.
🌐
Better Programming
betterprogramming.pub › 5-recipes-for-setting-default-props-in-react-typescript-b52d8b6a842c
5 Recipes for Setting Default Props in React and TypeScript | by Guillaume Renard | Better Programming
September 28, 2022 - If the attribute is present, the property will be automatically set to true, and if it’s omitted, it will be false (thanks to the default value). From this point, I will stop making a distinction between functions and components because, as we’ve seen, they are the same (they are both functions). Now let’s say that you wanted to accept a more complex argument in parameter: an object. That object itself is optional, and so are its properties.
🌐
GitHub
github.com › microsoft › TypeScript › issues › 31247
Default props not working in functional component · Issue #31247 · microsoft/TypeScript
May 4, 2019 - import React from "react"; interface Props { name: string; optional: string; } const Component = ({ name, optional = "default" }: Props) => ( <p>{name + " " + optional}</p> ); const Test = () => <Component name="test" />;
Author   AzureMarker
🌐
tutorialpedia
tutorialpedia.org › blog › how-to-specify-optional-default-props-with-typescript-for-stateless-functional-react-components
How to Specify Optional Default Props with TypeScript for Stateless Functional React Components — tutorialpedia.org
In React, default props ensure a component behaves consistently even when optional props are omitted. Historically, React supported a defaultProps property for components, but modern React (v16.8+) recommends using function default parameters for functional components.
🌐
The Web Dev
thewebdev.info › home › how to pass optional elements to a component as a prop in react?
How to pass optional elements to a component as a prop in React? - The Web Dev
November 6, 2021 - And we set Title as the value of Panel‘s children prop. So we see ‘hello world’ displayed in big text. To pass optional elements to a component as a prop in React, we can create a component that accepts the children prop.
🌐
React
legacy.reactjs.org › docs › components-and-props.html
Components and Props – React
However, if you integrate React into an existing app, you might start bottom-up with a small component like Button and gradually work your way to the top of the view hierarchy. Don’t be afraid to split components into smaller components. ... function Comment(props) { return ( <div className="Comment"> <div className="UserInfo"> <img className="Avatar" src={props.author.avatarUrl} alt={props.author.name} /> <div className="UserInfo-name"> {props.author.name} </div> </div> <div className="Comment-text"> {props.text} </div> <div className="Comment-date"> {formatDate(props.date)} </div> </div> ); }
🌐
CopyProgramming
copyprogramming.com › howto › how-to-specify-optional-default-props-with-typescript-for-stateless-functional-react-components
TypeScript Optional Props in React Components: Complete Guide for 2026
November 5, 2025 - Optional props are a fundamental pattern in React component design, allowing components to function with or without specific prop values. When building stateless functional React components with TypeScript, specifying optional properties requires careful attention to both type safety and runtime ...