Created
November 29, 2019 20:11
-
-
Save zeekrey/94fd34fae2f16c76a00ad26e83091310 to your computer and use it in GitHub Desktop.
[Typescript Functional Component Template] This is just my template for a new functional component written in React and Typescript. #react #typescript #functional-component
This file contains 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, { useState, useEffect, FunctionComponent } from "react" | |
import PropTypes from "prop-types" | |
type SubscribeProps = { | |
title: string | |
paragraph?: string | |
} | |
const Subscribe: FunctionComponent<SubscribeProps> = ({ | |
title, | |
paragraph = "default", | |
children, | |
}) => { | |
// Component state | |
const [status, setStatus] = useState("initalValue") | |
// Sideeffects like onLoad and stuff | |
useEffect(() => { | |
document.title = `Hello ${name}` | |
}, [name]) | |
return <div>hi</div> | |
} | |
Subscribe.propTypes = { | |
title: PropTypes.string.isRequired, | |
paragraph: PropTypes.string, | |
} | |
export default Subscribe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment