当前位置: 首页 > news >正文

react-11使用vscode开发react相关扩展插件(相关的快捷生成)

1.快速搭建react组件模板

2.相关搭建命令 

2.1 导入导出
前缀方法
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'
 2.2 函数相关
// anfn→ 箭头函数
(params) => { }// nfn→ 命名函数
const functionName = (params) => { }// dob→ 解构对象
const {propName} = objectToDescruct// dar→ 解构数组
const [propName] = arrayToDescruct
2.3 react导入
// imr→ 导入 React
import React from 'react'// imrd→ 导入 ReactDOM
import ReactDOM from 'react-dom'// imrc→ 导入 React 和 Component
import React, { Component } from 'react'// imrcp→ 导入 React、Component 和 PropTypes
import React, { Component } from 'react'
import PropTypes from 'prop-types'
2.4 生命周期
// cdm→ componentDidMount
componentDidMount = () => { }// cdup→ componentDidUpdate
componentDidUpdate = (prevProps, prevState) => { }// cwun→ componentWillUnmount
componentWillUnmount = () => { }
2.5 react类组件快速生成
// rcc→ 类组件
import React, { Component } from 'react'export default class FileName extends Component {render() {return <div>$2</div>}
}// rce→ 类组件带导出
import React, { Component } from 'react'export class FileName extends Component {render() {return <div>$2</div>}
}export default FileName
2.6 react函数组件快速生成
// rfce→ 函数组件带导出
import React from 'react'function FileName() {return <div>$0</div>
}export default FileName// rafc→ 箭头函数组件
import React from 'react'const FileName = () => {return <div>$0</div>
}export default FileName
2.7 PropTypes-类型定义
// pta→ PropTypes.array
PropTypes.array// ptar→ PropTypes.array.isRequired
PropTypes.array.isRequired// ptb→ PropTypes.bool
PropTypes.bool// ptbr→ PropTypes.bool.isRequired
PropTypes.bool.isRequired// pts→ PropTypes.string
PropTypes.string// ptsr→ PropTypes.string.isRequired
PropTypes.string.isRequired
 2.8 Redux 相关
// rxaction→ Redux Action
export const actionName = (payload) => ({type: 'ACTION_TYPE',payload
})// rxconst→ Redux Constant
export const ACTION_TYPE = 'ACTION_TYPE'// rxreducer→ Redux Reducer
const initialState = {}export default (state = initialState, { type, payload }) => {switch (type) {case typeName:return { ...state, ...payload }default:return state}
}
2.9 React Native 相关 
// rnc→ React Native 类���件
import React, { Component } from 'react'
import { View, Text } from 'react-native'export default class FileName extends Component {render() {return (<View><Text>$2</Text></View>)}
}// rncs→ React Native 类组件带样式
import React, { Component } from 'react'
import { Text, StyleSheet, View } from 'react-native'export default class FileName extends Component {render() {return (<View><Text>$2</Text></View>)}
}const styles = StyleSheet.create({})
2.10 控制台相关
// clg→ console.log
console.log(object)// clo→ console.log object with name
console.log('object', object)// ctr→ console.trace
console.trace(object)// cwa→ console.warn
console.warn(object)// cin→ console.info
console.info(object)

3.总结

转载于此博主仅做学习记录

插件:ES7+ React/Redux/GraphQL/React-Native snippets 使用指南VS Cod - 掘金

相关文章:

  • 用Playwright自动化网页测试,不只是“点点点”
  • 大型连锁酒店集团数据湖应用示例
  • 深度解析 MindTorch:无缝迁移 PyTorch 到 MindSpore 的高效工具
  • Centos离线安装Docker(无坑版)
  • 硬件工程师面试常见问题(10)
  • [250430] Kali Linux 存储库密钥丢失导致所有用户无法正常更新 APT
  • 如何使用C语言手搓斐波那契数列?
  • 【数学建模国奖速成系列】优秀论文绘图复现代码(二)
  • OCR身份证识别(正反面)_个人证照OCR识别_开放API接口使用指南
  • AI重构家居营销新范式:DeepSeek如何破解行业流量与转化困局?
  • 在pycharm中创建Django项目并启动
  • 在 API 模拟阶段:Apipost vs. Faker.js vs. Postman —— 为什么 Apipost 是最优选择
  • 科学数据可视化工具库visIt安装和使用
  • 「动态规划::背包」01背包 / AcWing 2(C++)
  • 解决 RN Switch 组件在安卓端样式很丑的问题
  • Databend 产品月报(2025年4月)
  • 人工智能数学基础(六):数理统计
  • 大屏/门户页面兼容各种分辨率或电脑缩放
  • 39.RocketMQ高性能核心原理与源码架构剖析
  • tailwindcss如何改变antd子组件的样式
  • 人民日报评论员:焕发风雨无阻、奋勇前行的精气神
  • 中央党校(国家行政学院)举行2025年春季学期第一批进修班毕业典礼
  • 屠呦呦当选美国国家科学院外籍院士
  • 探索演艺产业新路径,2万观众走进音乐科技融创节
  • 中共中央、国务院关于表彰全国劳动模范和先进工作者的决定
  • 上海乐高乐园建设进入最后冲刺,开园限量纪念年卡将于5月开售