Created
January 27, 2019 22:59
-
-
Save sixty-nine/f47dcf5bca8ee7e79f25b720e5753763 to your computer and use it in GitHub Desktop.
My react cheat sheet
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 * as React from 'react'; | |
// --- Component ---------------------------------------------------------------------------------- | |
type HelloProps = {}; | |
type HelloState = {}; | |
class Hello extends React.Component<HelloProps, HelloState> { | |
readonly state = {}; | |
constructor(props) { super(props) } | |
render() { | |
return ( | |
<div>Hello world</div> | |
) | |
} | |
} | |
// --- Functional --------------------------------------------------------------------------------- | |
const Hello: React.FunctionComponent<HelloProps> = ({ }) => ( | |
<div>Hello world</div> | |
); | |
const Hello = () => ( | |
<div>Hello world</div> | |
); | |
// --- Higher Order Components -------------------------------------------------------------------- | |
const HOC = WrappedComponent => { | |
return (props = {}) => { | |
return (<WrappedComponent {...props} />); | |
} | |
} | |
const HOC = WrappedComponent => props => ( | |
<WrappedComponent {...props} /> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment