美文网首页
vscode react snippets

vscode react snippets

作者: wlianfu | 来源:发表于2020-07-02 09:58 被阅读0次
    
        "hooks-comp": {
            "scope": "javascript, typescript, javascriptreact, typescriptreact",
            "prefix": "hooks-comp",
            "body": [
                "import React, { useEffect } from 'react';",
                "import { withRouter, RouteComponentProps } from 'react-router-dom';",
                "import { observer } from 'mobx-react';\n",
    
                "interface IProps extends RouteComponentProps {",
                    "\thistory: any,",
                "}",
                "interface IState {}\n",
    
                "const $1 = (props: IProps, state: IState) => {\n",
    
                    "\tuseEffect(() => {",
                        "\t\tconsole.log('enter $1...');\n",
    
                        "\t\treturn () => {",
                            "\t\t\tconsole.log('leave $1...');",
                        "\t\t};",
                    "\t});\n",
    
                    "\treturn (",
                        "\t\t<div>",
                            "\t\t\t<p>*** $1 ***</p>",
                        "\t\t</div>",
                    "\t);",
                "};\n",
    
                "export default withRouter(observer($1));\n",
            ],
            "description": "Basic React-Hooks component.",
        },
    

    相关文章

      网友评论

          本文标题:vscode react snippets

          本文链接:https://www.haomeiwen.com/subject/ecelqktx.html