Last active
January 22, 2022 16:57
-
-
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)
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'; | |
interface ChildProps { | |
message: string; | |
} | |
const Child = ({ message }: ChildProps) => { | |
return <div>{message}</div>; | |
}; | |
export default Child; |
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'; | |
interface ChildProps { | |
message: string; | |
} | |
const Child = (props: ChildProps) => { | |
return <div>{props.message}</div>; | |
}; | |
export default Child; |
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'; | |
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