Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Extension for Javascript/React snippets with search supporting ES7 and babel features

License

NotificationsYou must be signed in to change notification settings

nicoache1/vscode-es7-javascript-react-snippets

 
 

Repository files navigation

This extension provides you JavaScript, TypeScript, React Native and Reanimated 2 snippets in ES7 with Babel plugin features forVS Code

Installation

GitHub Repository Clone

Change to your.vscode/extensionsVS Code extensions directory.Depending on your platform it is located in the following folders:

  • Linux:~/.vscode/extensions
  • macOS:~/.vscode/extensions
  • Windows:%USERPROFILE%\.vscode\extensions

Clone the Material Theme repository asdsznajder.es7-react-js-snippets:

git clone https://github.com/nicoache1/vscode-es7-javascript-react-snippets nicoache1.es7-rn-reanimated2-ts-snippets

Search command

You can search through snippets withES7 snippet search command which can be run withCMD + Shift + P or just useCMD + Shift + R (CTRL + ALT + R for Windows & Linux) keybinding.

Supported languages (file extensions)

  • JavaScript (.js)
  • JavaScript React (.jsx)
  • TypeScript (.ts)
  • TypeScript React (.tsx)

Snippets info

Every space inside{ } and( ) means that this is pushed into next line :)$ represent each step aftertab.

TypeScript has own components and own snippets. Use search or just typets before every component snippet.

I.E.tsrcc

Basic Methods

PrefixMethod
imp→import moduleName from 'module'
imn→import 'module'
imd→import { destructuredModule } from 'module'
ime→import * as alias from 'module'
ima→import { originalName as aliasName} from 'module'
exp→export default moduleName
exd→export { destructuredModule } from 'module'
exa→export { originalName as aliasName} from 'module'
enf→export const functionName = (params) => { }
edf→export default (params) => { }
met→methodName = (params) => { }
fre→arrayName.forEach(element => { }
fof→for(let itemName of objectName { }
fin→for(let itemName in objectName { }
anfn→(params) => { }
nfn→const functionName = (params) => { }
dob→const {propName} = objectToDescruct
dar→const [propName] = arrayToDescruct
sti→setInterval(() => { }, intervalTime
sto→setTimeout(() => { }, delayTime
prom→return new Promise((resolve, reject) => { }
cmmb→comment block
cp→const { } = this.props
cs→const { } = this.state

React

PrefixMethod
imr→import React from 'react'
imrs→import React, { useState } from 'react'
imrse→import React, { useState, useEffect } from 'react'
redux→import { connect } from 'react-redux'
rconst→constructor(props) with this.state
rconc→constructor(props, context) with this.state
cdm→componentDidMount = () => { }
scu→shouldComponentUpdate = (nextProps, nextState) => { }
cdup→componentDidUpdate = (prevProps, prevState) => { }
cwun→componentWillUnmount = () => { }
gdsfp→static getDerivedStateFromProps(nextProps, prevState) { }
gsbu→getSnapshotBeforeUpdate = (prevProps, prevState) => { }

React Hooks

React Native

PrefixMethod
imrn→import { $1 } from 'react-native'
rnstyle→const styles = StyleSheet.create({})

Redux

PrefixMethod
rxaction→redux action template
rxconst→export const $1 = '$1'
rxreducer→redux reducer template
rxselect→redux selector template
rxslice→redux slice template

GraphQL

PrefixMethod
graphql→import { compose, graphql } from react-apollo'
expgql->export default compose(graphql($1, { name: $2 }))($3)

Console

PrefixMethod
clg→console.log(object)
clo→console.log("object", object)
ctm→console.time("timeId")
cte→console.timeEnd("timeId")
cas→console.assert(expression,object)
ccl→console.clear()
cco→console.count(label)
cdi→console.dir
cer→console.error(object)
cgr→console.group(label)
cge→console.groupEnd()
ctr→console.trace(object)
cwa→console.warn
cin→console.info

React Native Components

rnc

importReact,{Component}from'react'import{Text,View}from'react-native'exportdefaultclassFileNameextendsComponent{render(){return(<View><Text> $2</Text></View>)}}

rnf

importReactfrom'react'import{View,Text}from'react-native'exportdefaultfunction$1(){return(<View><Text> $2</Text></View>)}

rnfs

importReactfrom'react'import{StyleSheet,View,Text}from'react-native'exportdefaultfunction$1(){return(<View><Text> $2</Text></View>)}conststyles=StyleSheet.create({})

rnfe

importReactfrom'react'import{View,Text}from'react-native'const$1=()=>{return(<View><Text> $2</Text></View>)}exportdefault$1

rnfes

importReactfrom'react'import{StyleSheet,View,Text}from'react-native'const$1=()=>{return(<View><Text> $2</Text></View>)}exportdefault$1conststyles=StyleSheet.create({})

rncs

importReact,{Component}from'react'import{Text,StyleSheet,View}from'react-native'exportdefaultclassFileNameextendsComponent{render(){return(<View><Text> $2</Text></View>)}}conststyles=StyleSheet.create({})

rnce

importReact,{Component}from'react'import{Text,View}from'react-native'exportclassFileNameextendsComponent{render(){return(<View><Text> $2</Text></View>)}}exportdefault$1

tsrnfis

importReactfrom'react'import{View,Text,StyleSheet}from'react-native'interfacetestProps{}conststyles=StyleSheet.create({container:{alignItems:'center',flex:1,justifyContent:'center',},})exportconsttest:React.FC<testProps>=({})=>{return(<Viewstyle={styles.container}><Text>Hi</Text></View>)}

Reanimated

PrefixMethod
ianim→import Animated from 'react-native-reanimated'
useSharedValue→const value = useSharedValue<number>(0)

useDerivedValue

constderivedValue=useDerivedValue(()=>{return{}},[])

useAnimatedStyle

constanimatedStyle=useAnimatedStyle(()=>({transform:[{translateY:sharedValue.value}],}))

useAnimatedProps

constanimatedProps=useAnimatedProps(()=>{return{}})

animatedPanGesture

constgestureHandler=useAnimatedGestureHandler<PanGestureHandlerGestureEvent,{offsetY:number,offsetX:number}>({onActive:({ translationY},context)=>{translateY.value=translationY},onStart:(_event,context)=>{context.offsetY=translateY.value},})

animatedTapGesture

consttapGestureEvent=useAnimatedGestureHandler<TapGestureHandlerGestureEvent,any>({onActive:()=>{runOnJS(onPress)()},})

About

Extension for Javascript/React snippets with search supporting ES7 and babel features

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript100.0%

[8]ページ先頭

©2009-2025 Movatter.jp