Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>xm-snippetsNew to Visual Studio Code? Get it now.
xm-snippets

xm-snippets

xiangming

|
236 installs
| (1) | Free
some useful snippets for front-end
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

common

shortcut description
todo // TODO: ==== modify - delete ====
fixme // FIXME: ==== 待修复 ====
log console.log('log:------$1:$lineNumber------: ', $0);
divide-line、line-divide // ======================分隔线======================
///、、、、 /** */
、、 //
dgb、debugger debugger; // FIXME: ======== 需要删除 debugger ========

React

shortcut description
dp const { value } = props
dpc const { value } = this.props
dsc const { value } = this.state
do const { value } = objectName
da const [ value ] = arrayName
className | clm className={styles.}
cls import styles from './index.module.less'

func (component for javascript)

const Index = () => {
  return (
    <div>
      
    </div>
  );
};

export default Index;

func8 (function-component-typescript-react18)

import { FC } from 'react';

interface IProps {}

const Index: FC<IProps> = ({
  
}) => {

  return (
    <div>
      
    </div>
  );
};

export default Index;

reactComponent (component for class)

import React, { Component } from 'react';
import PropTypes from 'prop-types';

export default class Index extends Component {
  static propTypes = {};

  constructor(props) {
    super(props);

    this.state = {

    };
  }
  static getDerivedStateFromProps(props, state) {}

  componentDidMount() {
    // do something
  }

  shouldComponentUpdate(nextProps, nextState) {}

  getSnapshotBeforeUpdate(prevProps, prevState) {}

  componentDidUpdate(prevProps, prevState, snapshot) {}

  componentWillUnmount() {
    // do something
  }

  render() {
    return (
      <div>这里是组件</div>
    );
  }
}

Hooks

useEffect

useEffect(() => {

}, []);

useCallback

useCallback(() => {

}, []);

useMemo

useMemo(() => {}, []);

useState

const [, set] = useState();

useRef

const $1Ref = useRef($0);

useImperativeHandle

useImperativeHandle(ref, () => ({

}), []);
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft