使用Simple React Snippets VSCode扩展更快地编写React

news/2024/7/8 2:03:53

I’m a big fan of speeding up every part of your development. If you shave off seconds here and there multiple times a day, you’ll save a ton of time over the course of a year.

我非常乐于加速开发的每个部分。 如果您每天在这里和那里多次剃光,那么一年中将节省大量时间。

This involves using the keyboard as often as possible and reaching for the mouse as little as possible. It’s a goal of mine to do an entire day without touching the mouse. Still haven’t gotten there.

这涉及尽可能多地使用键盘,并尽可能少地接触鼠标 。 我的目标是整天不触摸鼠标。 还没到那儿。

Learning vim is a big part to being productive in your editor. Even putting vim in your browser with Vimium helps a ton.

学习vim是提高编辑效率的重要部分。 即使使用Vimium将vim放入浏览器也可以帮助很多。

Snippets are another way to save time on development. Simple React Snippets for VS Code by Burke Holland is a great way to speed up development.

片段是节省开发时间的另一种方法。 Burke Holland的 VS Code的简单React代码段是加速开发的好方法。

Here’s imrc expanded to import React, { Component } from 'react';

这是将imrc扩展为import React, { Component } from 'react';

扩展名 (The Extension)

Simple React Snippets can be found in the VS Code Extension Marketplace

可以在VS Code Extension Marketplace中找到简单的React代码段

一个简单的例子 (A Quick Example)

Whenever starting a new React file, I’ll use the imr or imrc snippets.

每当启动新的React文件时,我都会使用imrimrc段。

  • imr -> import React from 'react'

    imr > import React from 'react'

  • imrc -> import React, { Component } from 'react'

    imrc > import React, { Component } from 'react' imrc import React, { Component } from 'react'

片段 (The Snippets)

After installing the VS Code Extension (may have to restart VS Code?), you can use the snippets by typing the shortcut and hitting Tab or Enter.

安装VS Code Extension(可能需要重新启动VS Code?)之后,可以通过键入快捷方式并单击TabEnter来使用代码段。

Here are some helpful snippets when starting new files:

在启动新文件时,以下是一些有用的代码片段:

imr-导入React (imr - Import React)

import React from 'react';

imrc-导入React和组件 (imrc - Import React and Component)

import React, { Component } from 'react';

cc-制作类组件并导出 (cc - Make a Class Component and export)

class | extends Component {
  state = { | },
  render() {
    return ( | );
  }
}

export default |;

sfc-制作无状态功能组件 (sfc - Make a stateless function component)

const | = props => {
  return ( | );
};

export default |;

CDM-componentDidMount (cdm - componentDidMount)

componentDidMount() {
  |
}

cdu-componentDidUpdate (cdu - componentDidUpdate)

componentDidUpdate(prevProps, prevState) {
  |
}

ss-setState (ss - setState)

this.setState({ | : | });

任-渲染 (ren - render)

render() {
  return (
    |
  );
}

结论 (Conclusion)

There are a few more snippets that you can use that you can find on the official page.

您还可以在官方页面上找到更多的摘要。

翻译自: https://www.digitalocean.com/community/posts/write-react-faster-with-simple-react-snippets


http://www.niftyadmin.cn/n/3649317.html

相关文章

H5前端基础——css

CSS叫做层叠样式表&#xff0c;用来设置页面中元素的样式。背景颜色、字体颜色、字体大小。。。 CSS负责结构、表现、行为中的表现 编写的位置 1.内联样式 将样式编写到标签的style属性中 <p style"color:red;"></p> 这种样式只会对当前标签起作用&#…

[dotNET]用HttpWebRequest加载证书建立SSL通道时发生异常的解决办法

用HttpWebRequest加载证书建立SSL通道时发生异常的解决办法UltraPower关键字&#xff1a;HttpWebRequest,SSL,X509CertificatedotNet Framwork 1.1编写时间&#xff1a;2005-3-29WSE 2.0 SP3目的&#xff1a;对于用HttpWebRequest加载证书请求远端https服务器时&#xff0c;发…

prisma orm_Prisma中的身份验证-第3部分:验证

prisma ormIn Part 2 of this series we covered how to generate a temporary token for our user whenever they login or create an account. Now we’re going to wrap it up by restricting our data to only certain authorized users. 在本系列的第2部分中&#xff0c;我…

H5前端基础——盒子模型

CSS中将每一个元素都设置为了一个矩形的盒子 将所有的元素都设置为盒子&#xff0c;是为了方便页面的布局 当这些元素都是盒子以后&#xff0c;我们的布局就变成了在页面中摆放盒子 盒子模型 每个盒子都由如下几部分构成 内容区 内容区相当于盒子存放东西的空间 内容区在盒子的…

H5前端基础——布局

浮动 使用float来设置元素浮动 可选值 none 默认值&#xff0c;不浮动&#xff0c;元素在文档流中 left 元素向左浮动 right 元素向右浮动 特点 1.元素浮动以后会完全脱离文档流 2.浮动以后元素会一直向父元素的最上方移动 3.直到遇到父元素的边框或者其他的浮动元素&#x…

盖茨比乔布斯_使用盖茨比的useStaticQuery挂钩的快速指南

盖茨比乔布斯The useStaticQuery React Hook was added to Gatsby.js starting with version 2.1.0, and it’s an incredibly convenient way to make (build-time) GraphQL queries from any component within a Gatsby site. In this quick lesson, we’ll go over how to i…

客户端封装Fragment和Activity

一、封装activity public abstract class Activity extends AppCompatActivity {Overrideprotected void onCreate(Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);initWindows();if (initargs(getIntent().getExtras())) {// 得到界面Id并设置到Ac…

Android Studio中的手机通讯录开发

Android Studio中的手机通讯录&#xff0c;包含功能&#xff08;按首字母排序&#xff0c;动态添加&#xff09; 第一次写博客&#xff0c;也刚踏入工作&#xff0c;想着把自己在项目中遇到的问题&#xff0c;以及自己在工作中所做的项目记录下来&#xff0c;方便以后自己查找…