Last active
May 28, 2022 11:37
-
-
Save rudfoss/30615a4e8b99dece4a387b9b2b854973 to your computer and use it in GitHub Desktop.
React functional component with extended props
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
// This can be defined in some other file as well. | |
interface SharedProps { | |
active: boolean | |
title?: string | |
} | |
type MyProps = Omit<SharedProps, "title"> & { | |
specialTitle: string | |
} | |
export const ExtendedPropsComponent = ({active, specialTitle = ""}: MyProps) => { | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment