Skip to content

Instantly share code, notes, and snippets.

@markodayan
Last active January 22, 2022 16:57
Show Gist options
  • Save markodayan/7f256f70a1191e78ac4bdd08f9e7c6a6 to your computer and use it in GitHub Desktop.
Save markodayan/7f256f70a1191e78ac4bdd08f9e7c6a6 to your computer and use it in GitHub Desktop.
React TypeScript child examples (destructureProps most recommended - React FC not necessary anymore for the most part)
import React from 'react';
interface ChildProps {
message: string;
}
const Child = ({ message }: ChildProps) => {
return <div>{message}</div>;
};
export default Child;
import React from 'react';
interface ChildProps {
message: string;
}
const Child = (props: ChildProps) => {
return <div>{props.message}</div>;
};
export default Child;
import React from 'react';
interface ChildProps {
message: string;
}
const Child: React.FC<ChildProps> = ({ message }) => {
return <div>{message}</div>;
};
export default Child;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment