-
-
Save rcarton/7be0106e85627bdc540c1ffed2d446f1 to your computer and use it in GitHub Desktop.
Put this in React typescript snippets
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
"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