M. Herold
M. Herold

Reputation: 714

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

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

e.g. http://g.recordit.co/ZpuzipGyuU.gif

Related question: How do I inline gifs on Stack Overflow?

Thanks in advance!

Upvotes: 3

Views: 604

Answers (2)

Soon Santos
Soon Santos

Reputation: 2219

Reactjs code snippets has 692,658 installs at this time and seems to be a good choice!

You can easily install it by choosing Extensions (Ctrl+Shift+X) in the left panel of Visual Code and typing 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

Upvotes: 0

Abhishek
Abhishek

Reputation: 1714

I'm using this extension React Snippet Pack, not exactly autocomplete but quite useful.

Upvotes: 1

Related Questions