Skip to content

Instantly share code, notes, and snippets.

@kirkbyers
Created August 30, 2017 22:22
Show Gist options
  • Select an option

  • Save kirkbyers/337dc6ac6cd241c8a6ef0af0960bed2c to your computer and use it in GitHub Desktop.

Select an option

Save kirkbyers/337dc6ac6cd241c8a6ef0af0960bed2c to your computer and use it in GitHub Desktop.
A tsx snippet to quickly scaffold out redux containers
"React Container": {
"prefix": "rx-container",
"body": [
"import * as React from 'react';",
"import { Dispatch, connect } from 'react-redux';",
"",
"import { State } from '../reducers';",
"",
"interface Props { }",
"interface StateProps { }",
"interface DispatchProps { }",
"type ComponentProps = Props & StateProps & DispatchProps;",
"",
"interface ComponentState { }",
"",
"class ${1:ComponentName} extends React.Component<ComponentProps, ComponentState> {",
"\trender() {",
"\t\treturn (<div />);",
"\t}",
"}",
"",
"const mapStateToProps = (state: State): StateProps => ({});",
"const mapDispatchToProps = (dispatch: Dispatch<State>): DispatchProps => ({});",
"export default connect<StateProps, DispatchProps, Props>",
" (mapStateToProps, mapDispatchToProps)(${1:ComponentName});"
],
"description": "Scafolding for a container component"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment