Last active
April 1, 2022 00:44
-
-
Save imdadul/11fa591ef23d22685f36f08ac898ab1e to your computer and use it in GitHub Desktop.
Writing test only for public functions.
This file contains 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
const Parent: React.FC = () => { | |
return <ChildWrapper cat="mew" /> | |
} | |
type ChildProps = { | |
cat: string | |
} | |
const Child: React.FC<ChildProps & { global: string }> = ({ cat }) => { | |
return <span>{cat}</span> | |
} | |
const WithGlobal = | |
<P extends object>(Component: React.ComponentType<P & { global: string }>): React.FC<P> => | |
({ ...props }: P) => { | |
return <Component global="global" {...props} /> | |
} | |
const ChildWrapper = WithGlobal(Child) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment