Skip to content

Commit d90f87a

Browse files
committed
feat: add React.lazy import converter
1 parent 17a8f0c commit d90f87a

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

snippets/javascript.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,15 @@
362362
"description": "React HOC",
363363
"scope": "javascript,javascriptreact"
364364
},
365+
"🟨 reactLazy": {
366+
"prefix": "_rLazy.$_rLazy",
367+
"body": [
368+
"${TM_SELECTED_TEXT/(import )(\\w+)( from )([^;\r\n]+)([;])?/const $2 = lazy(() => import($4))$5/g}",
369+
""
370+
],
371+
"description": "Convert import to React.lazy import",
372+
"scope": "javascript,javascriptreact"
373+
},
365374
"🟨 useState": {
366375
"prefix": "useState.$useState",
367376
"body": [

snippets/typescript.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,15 @@
362362
"description": "React HOC",
363363
"scope": "javascript,typescript,javascriptreact,typescriptreact"
364364
},
365+
"🟨 reactLazy": {
366+
"prefix": "_rLazy.$_rLazy",
367+
"body": [
368+
"${TM_SELECTED_TEXT/(import )(\\w+)( from )([^;\r\n]+)([;])?/const $2 = lazy(() => import($4))$5/g}",
369+
""
370+
],
371+
"description": "Convert import to React.lazy import",
372+
"scope": "javascript,typescript,javascriptreact,typescriptreact"
373+
},
365374
"🟦 TS ReactFnComp": {
366375
"prefix": "rFC.TS.$$rFC.(type)",
367376
"body": [

src/snippets/react.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,11 @@ export const hocComponent: Snippet = {
162162
],
163163
description: 'React HOC',
164164
};
165+
166+
export const reactLazy: Snippet = {
167+
prefix: '_rLazy',
168+
body: [
169+
'${TM_SELECTED_TEXT/(import )(\\w+)( from )([^;\r\n]+)([;])?/const $2 = lazy(() => import($4))$5/g}',
170+
],
171+
description: 'Convert import to React.lazy import',
172+
};

0 commit comments

Comments
 (0)