Created
March 3, 2022 15:00
-
-
Save sebastiandg7/72605fc3df5a42fa80cc1034e48e27b9 to your computer and use it in GitHub Desktop.
JSX Component with generics
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'; | |
export interface FadeInViewProps { | |
reset?: boolean; | |
} | |
function FadeInView<T>(props: FadeInViewProps & T) { | |
const { reset, ...rest } = props; | |
return reset ? <div {...rest}> </div> : <div {...rest} />; | |
} | |
interface OtherProps { | |
hi: string; | |
} | |
const App = () => { | |
return ( | |
<> | |
<FadeInView<OtherProps> hi='hola' reset/> | |
</> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment