vs代码use片段的useState React

时间:2019-10-02 23:14:00

标签: reactjs visual-studio-code react-hooks vscode-snippets

仅尝试为useState()创建VS代码用户代码段

当前拥有

  "use state": {
    "prefix": "us",
    "body": [
      "const [$1, set${1/(.*)/${1:/upcase}/}] = useState($2);",
      "$3"
    ],
    "description": "creates use state"
  },

当我在$ 1(位置1)输入foo时,我得到

const [foo, setFOO] as useState()

想要

const [foo, setFoo] as useState()

有任何想法或了解任何具有反作用摘录片段的好网站吗?

谢谢

1 个答案:

答案 0 :(得分:0)

您只需要将转换更改为capitalize,例如:

"const [$1, set${1/(.*)/${1:/capitalize}/}] = useState($2);",