Skip to content

Instantly share code, notes, and snippets.

@sixty-nine
Created January 27, 2019 22:59
Show Gist options
  • Save sixty-nine/f47dcf5bca8ee7e79f25b720e5753763 to your computer and use it in GitHub Desktop.
Save sixty-nine/f47dcf5bca8ee7e79f25b720e5753763 to your computer and use it in GitHub Desktop.
My react cheat sheet
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