A "useState" VS Code Snippet

VS CodeReact

Create the following snippet, for JavaScript, TypeScript, and any other languages that look similar enough in order for the following snippet to work mostly fine.

"useState": {
"prefix": "useState",
"body": "const [${1}, set${1/(^[a-zA-Z])(.*)/${1:/upcase}${2}/}] = useState(${2:default${1/(^[a-zA-Z])(.*)/${1:/upcase}${2}/}});",
"description": "Use state, but for React"

The reason why I claim that it's preferable to create a snippet for both TypeScript and JavaScript but not their React variants, is because useState can also work inside a custom hook. Custom hooks don't need JSX.

Edit this page
Want to make your own site like this? Try gatsby-theme-code-notes by Zander Martineau.
Notes on code. My second brain, by Sal Rahman.