Skip to content

Instantly share code, notes, and snippets.

@imdadul
Last active April 1, 2022 00:44
Show Gist options
  • Save imdadul/11fa591ef23d22685f36f08ac898ab1e to your computer and use it in GitHub Desktop.
Save imdadul/11fa591ef23d22685f36f08ac898ab1e to your computer and use it in GitHub Desktop.
Writing test only for public functions.
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