Created
November 21, 2019 06:44
-
-
Save LinZap/cbc113a3e852b734ac4b9cd361cbe4e8 to your computer and use it in GitHub Desktop.
VS Code React Snippet
This file contains hidden or 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
{ | |
"container": { | |
"prefix": "rrdc", | |
"body": [ | |
"import ${TM_FILENAME_BASE} from '../../components${1}'", | |
"import { connect } from 'react-redux'", | |
"", | |
"function mapStateToProps(state){", | |
" return {", | |
" ${2}", | |
" }", | |
"}", | |
"", | |
"function mapDispatchToProps(dispatch){", | |
" return {", | |
" ${3}", | |
" }", | |
"}", | |
"", | |
"export default connect(", | |
" mapStateToProps,", | |
" mapDispatchToProps", | |
")(${TM_FILENAME_BASE})", | |
"" | |
], | |
"description": "container" | |
}, | |
"import prop-types": { | |
"prefix": "ip", | |
"body": [ | |
"import propTypes from 'prop-types'" | |
], | |
"description": "import prop-types" | |
}, | |
"import @fortawesome/react-fontawesome": { | |
"prefix": "ic", | |
"body": [ | |
"import { FontAwesomeIcon as Icon } from '@fortawesome/react-fontawesome'" | |
], | |
"description": "import @fortawesome/react-fontawesome" | |
}, | |
"import react-bootstrap": { | |
"prefix": "ib", | |
"body": [ | |
"import { $0 } from 'react-bootstrap'" | |
], | |
"description": "import react-bootstrap" | |
}, | |
"import react-intl": { | |
"prefix": "ii", | |
"body": [ | |
"import { $0 } from 'react-intl'" | |
], | |
"description": "import react-intl" | |
}, | |
"import actions": { | |
"prefix": "ia", | |
"body": [ | |
"import { $0 } from 'actions'" | |
], | |
"description": "import actions" | |
}, | |
"import classNames": { | |
"prefix": "iclass", | |
"body": [ | |
"import classNames from 'classnames'" | |
], | |
"description": "import classnames" | |
}, | |
"static propTypes": { | |
"prefix": "stp", | |
"body": [ | |
"static propTypes = {", | |
"\t$0", | |
"}" | |
], | |
"description": "static propTypes" | |
}, | |
"static defaultProps": { | |
"prefix": "std", | |
"body": [ | |
"static defaultProps = {", | |
"\t$0", | |
"}" | |
], | |
"description": "static defaultProps" | |
}, | |
"saga_modal": { | |
"prefix": "sagaModal", | |
"body": [ | |
"import ModalDialog from '../../containers/ModalDialog'", | |
"import ErrorMsg from '../ErrorMsg'", | |
"", | |
"<ModalDialog id={${1}} icon={!${2}.error}>", | |
" <FormattedMessage", | |
" id={${2}.error ? '${3}' : '${4}'}", | |
" defaultMessage={${2}.error ? '${5}' : '${6}'}", | |
" />", | |
" <br />", | |
" {${2}.error && <ErrorMsg errmsg={${2}.errmsg} />}", | |
"</ModalDialog>" | |
], | |
"description": "saga Modal" | |
}, | |
"get_Sid": { | |
"prefix": "getSid", | |
"body": [ | |
"getSid = () => {", | |
" const { match } = this.props", | |
" const { ${1} } = match.params", | |
" return ${1} ? parseInt(${1}) : 0", | |
"}" | |
], | |
"description": "get sid from uri" | |
}, | |
"import_ErrorMsg": { | |
"prefix": "ierr", | |
"body": [ | |
"import ErrorMsg from '../ErrorMsg'" | |
], | |
"description": "import ErrorMsg component" | |
}, | |
"import_base_loading": { | |
"prefix": "loading", | |
"body": [ | |
"import BaseLoading from '../Base/BaseLoading'" | |
], | |
"description": "import baseloading component" | |
}, | |
"import_fontawesome_icon": { | |
"prefix": "icon", | |
"body": [ | |
"import { FontAwesomeIcon as Icon } from '@fortawesome/react-fontawesome'" | |
], | |
"description": "import @fortawesome/react-fontawesome component" | |
}, | |
"import_router_push": { | |
"prefix": "ipush", | |
"body": [ | |
"import { push } from 'connected-react-router'", | |
"push: (path, state) => dispatch(push(path, state)),", | |
], | |
"description": "import connected-react-router push action" | |
}, | |
"assign_array_for_init": { | |
"prefix": "isarray", | |
"body": [ | |
"const { ${0} } = state.kb", | |
"if (!Array.isArray(${0}.data)) ${0}.data = []" | |
], | |
"description": "assign array for init state value" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment