- Components
- Routing
- Single Page Applicaion
- Forms
- React Hooks
- Authentication
- Advanced Techniques
import 'module';import moduleName from 'module';import { } from 'module';require('package');const Name = require('Name');module.exports = { };export const functionName = (params) => {};export default function TEST(params) {};export default class className {};constructor(params) {}methodName(params) {}get propertyName() {}set propertyName(value) {}(params) => {}const name = (params) => {}.then(result => {})
.catch(err => {});forEach loop in ES6 syntax
array.forEach(currentItem => {});for ... of loop
for (const item of object) {}for ... in loop
for (const item in object) {}const {propertyName} = object;const [propertyName] = array; console.log(object); console.error(object); console.table(object);class component skeleton
import React, { Component } from 'react';
class TEST extends Component {
render() {
return (
<div>
</div>
);
}
}
export default TEST;class component skeleton with react-redux connect
import React, { Component } from 'react';
import { connect } from 'react-redux';
function mapStateToProps(state) {
return {
};
}
class TEST extends Component {
render() {
return (
<div>
</div>
);
}
}
export default connect(
mapStateToProps,
)(TEST);class component skeleton with prop types after the class
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class TEST extends Component {
render() {
return (
<div>
</div>
);
}
}
TEST.propTypes = {
};
export default TEST;class component skeleton without import and default export lines
class TEST extends Component {
render() {
return (
<div>
</div>
);
}
}class component without import statements
class TEST extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<div>
</div>
);
}
}
TEST.propTypes = {
};
export default TEST;class pure component skeleton with prop types after the class
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
class TEST extends PureComponent {
render() {
return (
<div>
</div>
);
}
}
TEST.propTypes = {
};
export default TEST;stateless component skeleton
import React from 'react';
const TEST = () => {
return (
<div>
</div>
);
};
export default TEST;stateless component with prop types skeleton
import React from 'react';
import PropTypes from 'prop-types';
const TEST = props => {
return (
<div>
</div>
);
};
TEST.propTypes = {
};
export default TEST;memoize stateless component skeleton
import React, { memo } from 'react';
const TEST = memo(() => {
return (
<div>
</div>
);
});
export default TEST;memoize stateless component with prop types skeleton
import React, { memo } from 'react';
import PropTypes from 'prop-types';
const TEST = memo((props) => {
return (
<div>
</div>
);
});
TEST.propTypes = {
};
export default TEST;stateless named function skeleton
import React from 'react';
function TEST(props) {
return (
<div>
</div>
);
}
export default TEST;stateless named function with prop types skeleton
import React from 'react';
import PropTypes from 'prop-types';
TEST.propTypes = {
};
function TEST(props) {
return (
<div>
</div>
);
}
export default TEST;stateless component with prop types and implicit return
import React from 'react';
const TEST = (props) => (
);
export default TEST;class component with flow types skeleton
import * as React from 'react';
type Props = {
};
type State = {
};
export class TEST extends React.Component<Props, State>{
render() {
return (
<div>
</div>
);
};
};stateless named function skeleton with flow types skeleton
import * as React from 'react';
type Props = {
};
export function TEST(props: Props) {
return (
<div>
</div>
);
};stateless component with flow types skeleton
import * as React from 'react';
type Props = {
};
export const TEST = (props: Props) => {
return (
<div>
</div>
);
};empty propTypes declaration
TEST.propTypes = {};empty defaultProps declaration
TEST.defaultProps = {};class default constructor with props
constructor(params) {}class default constructor with props and context
constructor(props, context) {
super(props, context);
}empty state object
this.state = {};componentWillMount method
componentWillMount() {}componentDidMount method
componentDidMount() {}componentWillReceiveProps method
componentWillReceiveProps(nextProps) {}shouldComponentUpdate method
shouldComponentUpdate(nextProps, nextState) {}componentWillUpdate method
componentWillUpdate(nextProps, nextState) {}componentDidUpdate method
componentDidUpdate(prevProps, prevState) {}componentWillUnmount metho
componentWillUnmount() {}getSnapshotBeforeUpdate method
getSnapshotBeforeUpdate(prevProps, prevState) {}static getDerivedStateFromProps method
static getDerivedStateFromProps(nextProps, prevState) {}componentDidCatch method
componentDidCatch(error, info) {}render method
render() {
return (
<div>
</div>
);
}this.setState with object as parameter
this.setState();this.setState with function as parameter
this.setState((state, props) => {
return { }
});this.props
this.props.this.state
this.state.binds the this of method inside the constructor
this. = this..bind(this);MapDispatchToProps redux function
function mapDispatchToProps(dispatch) {
return {
}
}| Trigger | Content |
|---|---|
| pta→ | PropTypes.array |
| ptar→ | PropTypes.array.isRequired |
| ptb→ | PropTypes.bool |
| ptbr→ | PropTypes.bool.isRequired |
| ptf→ | PropTypes.func |
| ptfr→ | PropTypes.func.isRequired |
| ptn→ | PropTypes.number |
| ptnr→ | PropTypes.number.isRequired |
| pto→ | PropTypes.object |
| ptor→ | PropTypes.object.isRequired |
| pts→ | PropTypes.string |
| ptsr→ | PropTypes.string.isRequired |
| ptsm→ | PropTypes.symbol |
| ptsmr→ | PropTypes.symbol.isRequired |
| ptan→ | PropTypes.any |
| ptanr→ | PropTypes.any.isRequired |
| ptnd→ | PropTypes.node |
| ptndr→ | PropTypes.node.isRequired |
| ptel→ | PropTypes.element |
| ptelr→ | PropTypes.element.isRequired |
| pti→ | PropTypes.instanceOf(ClassName) |
| ptir→ | PropTypes.instanceOf(ClassName).isRequired |
| pte→ | PropTypes.oneOf(['News', 'Photos']) |
| pter→ | PropTypes.oneOf(['News', 'Photos']).isRequired |
| ptet→ | PropTypes.oneOfType([PropTypes.string, PropTypes.number]) |
| ptetr→ | PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired |
| ptao→ | PropTypes.arrayOf(PropTypes.number) |
| ptaor→ | PropTypes.arrayOf(PropTypes.number).isRequired |
| ptoo→ | PropTypes.objectOf(PropTypes.number) |
| ptoor→ | PropTypes.objectOf(PropTypes.number).isRequired |
| ptoos→ | PropTypes.objectOf(PropTypes.shape()) |
| ptoosr→ | PropTypes.objectOf(PropTypes.shape()).isRequired |
| ptsh→ | PropTypes.shape({color: PropTypes.string, fontSize: PropTypes.number}) |
| ptshr→ | PropTypes.shape({color: PropTypes.string, fontSize: PropTypes.number}).isRequired |

