Skip to content

Instantly share code, notes, and snippets.

@AlienQbw
Last active November 22, 2021 04:37
Show Gist options
  • Save AlienQbw/b99994187828ae307ae846bfef2d722f to your computer and use it in GitHub Desktop.
Save AlienQbw/b99994187828ae307ae846bfef2d722f to your computer and use it in GitHub Desktop.
React Snippets

React Native Snippets

Basic Methods

Prefix Method
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) => { }
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

React

Prefix Method
imr→ import React from 'react'
imrc→ import React, { Component } from 'react'
imrpc→ import React, { PureComponent } from 'react'
imrm→ import React, { memo } from 'react'
redux→ import { connect } from 'react-redux'
rconst→ constructor(props) with this.state
cwm→ componentWillMount = () => { } DEPRECATED!!!
cdm→ componentDidMount = () => { }
cwr→ componentWillReceiveProps = (nextProps) => { } DEPRECATED!!!
scu→ shouldComponentUpdate = (nextProps, nextState) => { }
cwup→ componentWillUpdate = (nextProps, nextState) => { } DEPRECATED!!!
cdup→ componentDidUpdate = (prevProps, prevState) => { }
cwun→ componentWillUnmount = () => { }
sst→ this.setState({ })
ssf→ this.setState((state, props) => return { })
props→ this.props.propName
state→ this.state.stateName

React Native

Prefix Method
imrn→ import { $1 } from 'react-native'

Redux

Prefix Method
rxaction→ redux action template
rxconst→ export const $1 = '$1'
rxreducer→ redux reducer template

Console

Prefix Method
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 Hooks:


Gist created from this source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment