Skip to content

Instantly share code, notes, and snippets.

@godrix
Last active April 5, 2021 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godrix/a84bfc919b8ea945426de9fa84136b93 to your computer and use it in GitHub Desktop.
Save godrix/a84bfc919b8ea945426de9fa84136b93 to your computer and use it in GitHub Desktop.
Snippets for React, React native and styled-components
{
"useStateHook": {
"prefix": "uState",
"body": [
"const [${1:state}, set${2:State}] = useState(${3});"
],
"description": "Create useState"
},
"useEffectHook": {
"prefix": "uEffect",
"body": [
"useEffect(()=>{",
" ${1:// code}",
" },[]);"
],
"description": "Create useEffect"
},
"useEffectAsyncHook": {
"prefix": "uAEffect",
"body": [
"useEffect(()=> {",
" (async ()=>{",
" ${1:// await function}",
" })()",
" },[]);"
],
"description": "Create useEffect Async"
},
"useCallback": {
"prefix": "uCallback",
"body": [
"const ${1:name} = useCallback(() => {",
" ${2:// code}",
"}, [${3}]);"
],
"description": "Create useCallback function"
},
"Create React Native FC": {
"prefix": "rnfc",
"body": [
"import React from 'react';",
"import { View } from 'react-native';",
"",
"//import { Container } from './styles';",
"",
"",
"export function ${1:${TM_DIRECTORY/^.*(\\\\/|\\\\\\\\)([^(\\\\/|\\\\\\\\)]+)$/$2/}}() {",
" return <View />;",
"}"
],
"description": "Create React Native FC"
},
"Create React FC": {
"prefix": "rfc",
"body": [
"import React from 'react';",
"",
"// import { Container } from './styles';",
"",
"",
"export function ${1:${TM_DIRECTORY/^.*(\\\\/|\\\\\\\\)([^(\\\\/|\\\\\\\\)]+)$/$2/}}() {",
" return <View />;",
"}"
],
"description": "Create React FC"
},
"Create Styled RNFC": {
"prefix": "styledrn",
"body": [
"import styled from 'styled-components/native';",
"",
"export const Container = styled.View`",
" ",
"`;"
],
"description": "Create Styled RNFC"
},
"Create Styled RFC": {
"prefix": "styledreact",
"body": [
"import styled from 'styled-components';",
"",
"export const Container = styled.div`",
" ",
"`;"
],
"description": "Create Styled React"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment