Skip to content

Instantly share code, notes, and snippets.

@sebastiandg7
Created March 3, 2022 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastiandg7/72605fc3df5a42fa80cc1034e48e27b9 to your computer and use it in GitHub Desktop.
Save sebastiandg7/72605fc3df5a42fa80cc1034e48e27b9 to your computer and use it in GitHub Desktop.
JSX Component with generics
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