Reputation: 281
I'm trying to create a VS code user snippet for useState()
Currently I have
"use state": {
"prefix": "us",
"body": [
"const [$1, set${1/(.*)/${1:/upcase}/}] = useState($2);",
"$3"
],
"description": "creates use state"
},
When I enter 'foo' at $1 (position 1) I get:
const [foo, setFOO] as useState()
However I would like to get:
const [foo, setFoo] as useState()
How do I change my snippet to work this way?
Upvotes: 21
Views: 11259
Reputation: 1
You need to remove the "*", this character transforms all others to uppercase, without it, you will leave only the first uppercase.
"prefix": "us",
"body": [
"const [$1, set${1/(.)/${1:/upcase}/}] = useState($2);",
"$3"
],
"description": "creates use state"
},
Upvotes: 0
Reputation: 181639
You just need to change your transform to capitalize
like:
"const [$1, set${1/(.*)/${1:/capitalize}/}] = useState($2);",
Upvotes: 26