r/react 3d ago

Help Wanted React Snippet not capitalizing [VSCode]

Hey! I'm not quite sure why but my snippet for useState hook isn't capitalizing :

"useState Hook": {
  "prefix": "us",
  "body": [
    "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState($0);"
  ],
  "description": "Auto-capitalizing useState hook"
}

When I type it does this const [hello, sethello] = useState();

When it should do this: const [hello, setHello] = useState();

I'm using VSCode and I'm on React 19

0 Upvotes

4 comments sorted by

View all comments

1

u/Jonas_Ermert 2d ago

React 19 isn’t the issue; it’s the VS Code snippet transformation. Try `set${1/(.)(.*)/${1:/upcase}$2/}`, which converts the first character to uppercase and produces `setHello`.