Skip to content

Instantly share code, notes, and snippets.

@JaysonChiang
Created February 26, 2021 14:21
Show Gist options
  • Save JaysonChiang/bafb13cd50da1bf0172ac745ab2f2367 to your computer and use it in GitHub Desktop.
Save JaysonChiang/bafb13cd50da1bf0172ac745ab2f2367 to your computer and use it in GitHub Desktop.
TypeScript React Component with React.FC
interface ChildProps {
name: string;
onClick: () => void;
}
const Child: React.FC<ChildProps> = ({ name, onClick }) => {
return (
<div>
{name}
<button onClick={onClick}>Click</button>
</div>
);
};
export default Child;
import Child from './Child';
const Parent = () => {
return (
<Child name="jayson" onClick={() => console.log('test')}>
other children content here
</Child>
);
};
export default Parent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment