I\'m trying to create a stateless React component with optional props and defaultProps in Typescript (for a React Native project). This is trivial with vanilla JS, but I\'m stum
Here's how I like to do it:
type TestProps = { foo: Foo } & DefaultProps type DefaultProps = Partial const defaultProps = { title: 'Mr', name: 'McGee' } const Test = (props: Props) => { props = {...defaultProps, ...props} return ( {props.title} {props.name} ) } export default Test