Skip to content

Instantly share code, notes, and snippets.

@rcarton rcarton/snippet.json Secret

Last active Jul 28, 2020
Embed
What would you like to do?
Put this in React typescript snippets
"React Connected Component": {
"prefix": "cc",
"body": [
"import * as React from 'react'",
"import { connect } from 'react-redux'",
"",
"export interface OwnProps {}",
"interface StateProps {}",
"interface DispatchProps {}",
"",
"export type Props = OwnProps & StateProps & DispatchProps",
"",
"export class ${1:ComponentName} extends React.Component<Props, {}> {",
"\trender(): JSX.Element {",
"\t\treturn (",
"\t\t\t<div>",
"\t\t\t\t${1:ComponentName}",
"\t\t\t</div>",
"\t\t)",
"\t}",
"}",
"",
"export function mapStateToProps(state, ownProps: OwnProps): StateProps {",
"\treturn {}",
"}",
"",
"export function mapDispatchToProps(dispatch): DispatchProps { ",
"\treturn {}",
"}",
"",
"export default connect<StateProps, DispatchProps, OwnProps>(",
"\tmapStateToProps,",
"\tmapDispatchToProps",
")(${1:ComponentName})"
],
"description": "Connected React Component"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.