Last active
September 11, 2020 05:49
-
-
Save algera/7e131cfead1fbc1dfe10a9f129554cb6 to your computer and use it in GitHub Desktop.
React / Redux Code Snippets for Visual Studio Code
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
{ | |
"Jeff's Component": { | |
"scope": "javascript", | |
"prefix": "jfcom", | |
"body": [ | |
"import React from 'react'", | |
"// import PropTypes from 'prop-types'", | |
"import { Text, View } from 'react-native'", | |
"import styles from './index.styled'", | |
"", | |
"const $1Component = () => (", | |
" <View style={styles.view}>", | |
" <Text>$1Component </Text>", | |
" </View>", | |
")", | |
"", | |
"// $1Component.propTypes = {", | |
" //", | |
"// }", | |
"", | |
"export default $1Component", | |
"" | |
], | |
"description": "Jeff's Component" | |
}, | |
"Jeff's HOC Component": { | |
"scope": "javascript", | |
"prefix": "jfcomh", | |
"body": [ | |
"import React from 'react'", | |
"// import PropTypes from 'prop-types'", | |
"import { Text, View } from 'react-native'", | |
"import hoc from './hoc'", | |
"import styles from './index.styled'", | |
"", | |
"const $1 = () => (", | |
" <View style={styles.view}>", | |
" <Text>$1</Text>", | |
" </View>", | |
")", | |
"", | |
"// $1.propTypes = {", | |
" //", | |
"// }", | |
"", | |
"export default hoc($1)", | |
"" | |
], | |
"description": "Jeff's HOC Component" | |
}, | |
"Jeff's HOC": { | |
"scope": "javascript", | |
"prefix": "jfhoc", | |
"body": [ | |
"import React, { useState, useEffect } from 'react'", | |
"// import PropTypes from 'prop-types'", | |
"import { connect } from 'react-redux'", | |
"// import * as actions from '../../actions'", | |
"", | |
"const hoc = ($1Container) => {", | |
" const $1Hoc = (props) => {", | |
" const [something, setSomething] = useState(false)", | |
"", | |
" useEffect(() => {", | |
" setSomething(true)", | |
" }, [])" , | |
"", | |
" return (", | |
" <$1Container", | |
" {...props}", | |
" something={something}", | |
" />", | |
" )", | |
" }", | |
"", | |
" // $1Hoc.propTypes = {", | |
" // ", | |
" // }", | |
"", | |
" return $1Hoc", | |
"}", | |
"", | |
" //const mapStateToProps = ({ }) => ({", | |
" // ", | |
" //})", | |
"", | |
" //const mapDispatchToProps = {", | |
" // ", | |
" //}", | |
"", | |
" export default ($1Container) =>", | |
" connect(/*mapStateToProps, mapDispatchToProps*/)(", | |
" hoc($1Container)", | |
" )", | |
"", | |
], | |
"description": "Jeff's HOC" | |
}, | |
"Jeff's Stylesheet": { | |
"scope": "javascript", | |
"prefix": "jfss", | |
"body": [ | |
"import { StyleSheet } from 'react-native'", | |
"", | |
"export default StyleSheet.create({", | |
" view: {", | |
" flex: 1", | |
" },", | |
"})", | |
"" | |
], | |
"description": "Jeff's Stylesheet" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to functional component syntax with React hooks