-
-
Save amitmbee/b15d2741abc146a5e15422c7b9de5325 to your computer and use it in GitHub Desktop.
Stateless/dumb React component in Typescript
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
// stateless/dumb component in React Typescript | |
import * as React from 'react'; | |
interface IWelcomeProps { | |
name: string, | |
} | |
const Welcome: React.SFC<IWelcomeProps> = ({ name }) => { | |
return <h1>Hello, {name}</h1>; | |
} | |
Welcome.defaultProps = { | |
name: 'Guest User', // This value is adopted when name prop is omitted | |
} | |
export default Welcome; | |
// via https://medium.com/@iktakahiro/react-stateless-functional-component-with-typescript-ce5043466011 | |
// via https://firstdoit.com/how-to-write-a-react-stateless-functional-component-in-typescript-5d150419bbbc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment