Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>react-snippetNew to Visual Studio Code? Get it now.
react-snippet

react-snippet

leroy-magpie

|
950 installs
| (1) | Free
react 用户代码片段
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Usage

After install this snippets add this inside your settings

"editor.snippetSuggestions": "top",

im [引入]

import React from react;

zs [注释]

/**  */

dp [默认 props]

static defaultProps = {
  name:
}

ds [默认 state]

readonly state = {
  name:
}

gp [解构 props]

const {  } = props;

gtp [解构 this.props]

const {  } = this.props;

gs [解构 useState]

const [state, setState] = useState();

gts [解构 this.state]

const {  } = this.state;

go [解构对象]

const {  } = obj;

cs [setState]

this.setState({  });

ch [方法]

const handle = () => {

};

ph [私有方法]

private handle = () => {

}

tr [数据层]

try {
  await handle()
} catch (e) {
  console.error(e);
}

cl [className]

className=""

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft