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

“ES7+ React/Redux/React-Native snippets“常用快捷前缀

请注意,这是一个常用的列表,不是扩展提供的所有前缀。最完整和最新的列表请参考扩展的官方文档或在 VS Code 中查看扩展的详情页面。

React (通常用于 .js, .jsx, .ts, .tsx):

  • rfce: React Functional Component with Export Default
  • rafce: React Arrow Function Component with Export Default
  • rce: React Class Component with Export Default
  • rcc: React Class Component
  • rpc: React Pure Class Component
  • rconst: Adds constructor and super (in a class)
  • rprops: Adds defaultProps (in a class or functional component)
  • rpropst: Adds propTypes (in a class or functional component)
  • rstate: Adds state object (in a class)
  • rcontext: React Context boilerplate

React Hooks (通常用于 .js, .jsx, .ts, .tsx):

  • usf: useState hook template (e.g., const [name, setName] = useState(initialValue);)
  • useEffect: useEffect hook template
  • useRef: useRef hook template
  • useMemo: useMemo hook template
  • useCallback: useCallback hook template
  • useContext: useContext hook template
  • useReducer: useReducer hook template
  • useImperativeHandle: useImperativeHandle hook template
  • useLayoutEffect: useLayoutEffect hook template
  • useDebugValue: useDebugValue hook template

React Native (通常用于 .js, .jsx, .ts, .tsx):

  • rnfe: React Native Functional Component with Export Default
  • rnfce: React Native Functional Component with Export
  • rnsc: React Native Stylesheet Create (StyleSheet.create({}))
  • rnssc: React Native Stylesheet Create with styles constant (const styles = StyleSheet.create({}))
  • rncss: React Native Stylesheet Create shorthand (just styles)

Lifecycle Methods (Class Components):

  • cdm: componentDidMount
  • cdup: componentDidUpdate
  • cwunmount: componentWillUnmount
  • cdc: componentDidCatch
  • cgsb: getSnapshotBeforeUpdate
  • cserender: shouldComponentUpdate

Redux:

  • redux-reducer: Basic Redux reducer structure
  • redux-action: Basic Redux action creator structure

Other / Utilities:

  • imr: import React from 'react'
  • imrc: import React, { Component } from 'react'
  • imrpc: import React, { PureComponent } from 'react'
  • imrce: import React, { Component } from 'react' + Export Default (for class)
  • imp: Generic Import (import ... from ...)
  • impt: Generic Import Type (import type ... from ...)
  • impc: Generic Import CSS (import './style.css')
  • log: console.log()
  • clg: console.log() (similar to log)
  • clo: console.log(object)

再次提醒,这个列表涵盖了大多数你可能日常使用的片段。当你安装了扩展后,在编辑器中输入前缀时,VS Code 的智能感知也会弹出建议列表,这有助于你发现和记住更多的前缀。

http://www.xdnf.cn/news/5069.html

相关文章:

  • Vue 生命周期详解
  • com.fasterxml.jackson.dataformat.xml.XmlMapper把对象转换xml格式,属性放到标签<>里边
  • 部署Superset BI(四)连接sql server数据库
  • CNG汽车加气站操作工岗位职责
  • 2025医疗信息化趋势:健康管理系统如何重构智慧医院生态
  • 李沐《动手学深度学习》 | 多层感知机
  • WEB前端表单及表格标签综合案例
  • World of Warcraft [CLASSIC][80][Deluyia] [Fragment of Val‘anyr]
  • Dify智能体平台源码二次开发笔记(8)- OpenAvatarChat数字人项目+dify智能体完美融合
  • 升级 Azure Kubernetes 服务群集的关键注意事项
  • Spring Cloud LoadBalancer (负载均衡)
  • Kubernetes生产实战:NodePort端口范围的隐藏规则与调优指南
  • C——数组和函数实践:扫雷
  • 【PostgreSQL数据分析实战:从数据清洗到可视化全流程】电商数据分析案例-9.4 可视化报告输出
  • 两台服务器之前共享文件夹
  • 第十五章,SSL VPN
  • 一文了解氨基酸的分类、代谢和应用
  • Spring Web MVC基础理论和使用
  • Missashe考研日记-day36(改版说明)
  • AWS之数据分析类产品
  • 算法与数据结构 - 二叉树结构入门
  • git高效杀器——cz-customizable 搭配 commitlint
  • SAF利用由Varjo和AFormX开发的VR/XR模拟器推动作战训练
  • 【2025最新】如何定制化、高效化使用LIghtRAG进行规范知识抽取
  • STM32TIM定时中断(6)
  • 聊聊Spring AI autoconfigure模块的拆分
  • 香港科技大学(广州)新开设智能制造理学硕士学位项目线上招生宣讲会
  • 切比雪夫不等式详解
  • Vibe Coding: 优点与缺点
  • 在 Kotlin 中什么是委托属性,简要说说其使用场景和原理