简体   繁体   English

如何让 VS Code 自动完成 React 生命周期方法?

[英]How do I get VS Code to autocomplete React lifecycle methods?

How do I get VS Code to autocomplete React lifecycle methods?如何让 VS Code 自动完成 React 生命周期方法?

eg http://g.recordit.co/ZpuzipGyuU.gif例如http://g.recordit.co/ZpuzipGyuU.gif

Related question: How do I inline gifs on Stack Overflow?相关问题:如何在 Stack Overflow 上内联 gif?

Thanks in advance!提前致谢!

我正在使用这个扩展React Snippet Pack ,不是完全自动完成但非常有用。

Reactjs code snippets has 692,658 installs at this time and seems to be a good choice! Reactjs 代码片段此时有 692,658 次安装,似乎是一个不错的选择!

You can easily install it by choosing Extensions (Ctrl+Shift+X) in the left panel of Visual Code and typing Reactjs code snippets .您可以通过在 Visual Code 的左侧面板中选择Extensions (Ctrl+Shift+X)并键入Reactjs code snippets来轻松安装它。

Although you need to type-specific things to get your methods completed, for example, if you type.尽管您需要键入特定的东西才能完成您的方法,例如,如果您键入。

Type the first one and you will see the power of this extension!输入第一个,您将看到此扩展的强大功能!

rcc→    class component skeleton
rrc→    class component skeleton with react-redux connect
rrdc→   class component skeleton with react-redux connect and dispatch

cwm→    componentWillMount method
cdm→    componentDidMount method
cwr→    componentWillReceiveProps method
scu→    shouldComponentUpdate method
cwup→   componentWillUpdate method
cdup→   componentDidUpdate method
cwun→   componentWillUnmount method
gsbu→   getSnapshotBeforeUpdate method

ren→    render method

It has a pattern, you just need to type each first letter of each word of the method, or the first three letters when it has only one word.它有一个模式,你只需要输入方法的每个单词的第一个字母,或者当它只有一个单词时输入前三个字母。 And it will complete automatically for you.它会自动为您完成。

You can see all the options in the Visual Studio Market Place, Extension Overview您可以在Visual Studio Market Place、扩展概述中看到所有选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM