Skip to content

Commit 569c294

Browse files
committed
feat: add elm with dangerouslySetInnerHTML prop snippet
1 parent 241c80d commit 569c294

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

snippets/javascript.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,15 @@
11651165
"description": "Wrap with `JSON.parse`",
11661166
"scope": "javascript,javascriptreact"
11671167
},
1168-
"🟨 htmlButton": {
1168+
"🟨 jsxInnerHTML": {
1169+
"prefix": "innerHTML.$innerHTML.dangerously",
1170+
"body": [
1171+
"<${1:div} dangerouslySetInnerHTML={{ __html: $2 }} />"
1172+
],
1173+
"description": "Create element with `dangerouslySetInnerHTML` prop",
1174+
"scope": "javascript,javascriptreact"
1175+
},
1176+
"🟨 jsxButton": {
11691177
"prefix": "button.$button",
11701178
"body": [
11711179
"<button type=\"button\" onClick={${2:onClick}}$3>",

snippets/typescript.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,15 @@
14621462
"description": "Wrap with `JSON.parse`",
14631463
"scope": "javascript,typescript,javascriptreact,typescriptreact"
14641464
},
1465-
"🟨 htmlButton": {
1465+
"🟨 jsxInnerHTML": {
1466+
"prefix": "innerHTML.$innerHTML.dangerously",
1467+
"body": [
1468+
"<${1:div} dangerouslySetInnerHTML={{ __html: $2 }} />"
1469+
],
1470+
"description": "Create element with `dangerouslySetInnerHTML` prop",
1471+
"scope": "javascript,typescript,javascriptreact,typescriptreact"
1472+
},
1473+
"🟨 jsxButton": {
14661474
"prefix": "button.$button",
14671475
"body": [
14681476
"<button type=\"button\" onClick={${2:onClick}}$3>",

src/snippets/html-jsx.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { Snippet } from '../types';
22

3-
export const htmlButton: Snippet = {
3+
export const jsxInnerHTML: Snippet = {
4+
prefix: ['innerHTML', 'dangerously'],
5+
body: ['<${1:div} dangerouslySetInnerHTML={{ __html: $2 }} />'],
6+
description: 'Create element with `dangerouslySetInnerHTML` prop',
7+
};
8+
9+
export const jsxButton: Snippet = {
410
prefix: 'button',
511
body: ['<button type="button" onClick={${2:onClick}}$3>', '\t${1:Button}', '</button>'],
612
description: 'Create `<button />` element',

0 commit comments

Comments
 (0)