@enjoys/context-engine 1.2.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/codeActions/angular.json +126 -0
- package/data/codeActions/css.json +111 -0
- package/data/codeActions/nestjs.json +124 -0
- package/data/codeActions/nextjs.json +198 -0
- package/data/codeActions/react.json +154 -0
- package/data/codeActions/shadcn.json +112 -0
- package/data/codeActions/shell.json +169 -26
- package/data/codeActions/tailwindcss.json +76 -0
- package/data/codeLens/angular.json +22 -0
- package/data/codeLens/css.json +68 -0
- package/data/codeLens/nestjs.json +21 -0
- package/data/codeLens/nextjs.json +117 -0
- package/data/codeLens/react.json +89 -0
- package/data/codeLens/shadcn.json +89 -0
- package/data/codeLens/shell.json +59 -17
- package/data/codeLens/tailwindcss.json +103 -0
- package/data/color/angular.json +21 -0
- package/data/color/css.json +124 -0
- package/data/color/nestjs.json +18 -0
- package/data/color/nextjs.json +22 -0
- package/data/color/react.json +93 -0
- package/data/color/shadcn.json +66 -0
- package/data/color/shell.json +106 -80
- package/data/color/tailwindcss.json +53 -0
- package/data/commands/angular.json +312 -0
- package/data/commands/css.json +41 -0
- package/data/commands/manifest.json +734 -727
- package/data/commands/nestjs.json +273 -0
- package/data/commands/nextjs.json +123 -0
- package/data/commands/react.json +210 -0
- package/data/commands/shadcn.json +410 -0
- package/data/commands/shell.json +571 -41
- package/data/commands/tailwindcss.json +53 -0
- package/data/completion/angular.json +1490 -0
- package/data/completion/css.json +1176 -0
- package/data/completion/javascript.json +27 -0
- package/data/completion/nestjs.json +1454 -0
- package/data/completion/nextjs.json +1373 -0
- package/data/completion/react.json +1319 -0
- package/data/completion/redis-cli.json +1 -1
- package/data/completion/shadcn.json +1202 -0
- package/data/completion/shell.json +2446 -510
- package/data/completion/tailwindcss.json +284 -0
- package/data/completion/typescript.json +27 -0
- package/data/declaration/angular.json +46 -0
- package/data/declaration/css.json +59 -0
- package/data/declaration/nestjs.json +47 -0
- package/data/declaration/nextjs.json +274 -0
- package/data/declaration/react.json +199 -0
- package/data/declaration/shadcn.json +211 -0
- package/data/declaration/shell.json +343 -24
- package/data/declaration/tailwindcss.json +137 -0
- package/data/definition/angular.json +670 -0
- package/data/definition/css.json +115 -0
- package/data/definition/nestjs.json +684 -0
- package/data/definition/nextjs.json +439 -0
- package/data/definition/react.json +397 -0
- package/data/definition/redis-cli.json +1 -1
- package/data/definition/shadcn.json +99 -0
- package/data/definition/shell.json +820 -0
- package/data/definition/tailwindcss.json +115 -0
- package/data/documentHighlight/angular.json +414 -0
- package/data/documentHighlight/css.json +125 -0
- package/data/documentHighlight/nestjs.json +115 -0
- package/data/documentHighlight/nextjs.json +212 -0
- package/data/documentHighlight/react.json +119 -0
- package/data/documentHighlight/shadcn.json +168 -0
- package/data/documentHighlight/shell.json +664 -334
- package/data/documentHighlight/tailwindcss.json +160 -0
- package/data/documentRangeFormatting/angular.json +45 -0
- package/data/documentRangeFormatting/css.json +101 -0
- package/data/documentRangeFormatting/nestjs.json +17 -0
- package/data/documentRangeFormatting/nextjs.json +17 -0
- package/data/documentRangeFormatting/react.json +78 -0
- package/data/documentRangeFormatting/shadcn.json +45 -0
- package/data/documentRangeFormatting/shell.json +120 -53
- package/data/documentRangeFormatting/tailwindcss.json +55 -0
- package/data/documentSymbol/angular.json +180 -0
- package/data/documentSymbol/css.json +96 -0
- package/data/documentSymbol/nestjs.json +152 -0
- package/data/documentSymbol/nextjs.json +159 -0
- package/data/documentSymbol/react.json +145 -0
- package/data/documentSymbol/shadcn.json +131 -0
- package/data/documentSymbol/shell.json +166 -26
- package/data/documentSymbol/tailwindcss.json +110 -0
- package/data/foldingRange/angular.json +99 -0
- package/data/foldingRange/css.json +66 -0
- package/data/foldingRange/nestjs.json +26 -0
- package/data/foldingRange/nextjs.json +26 -0
- package/data/foldingRange/react.json +120 -0
- package/data/foldingRange/shadcn.json +93 -0
- package/data/foldingRange/shell.json +106 -46
- package/data/foldingRange/tailwindcss.json +60 -0
- package/data/formatting/angular.json +21 -0
- package/data/formatting/css.json +73 -0
- package/data/formatting/nestjs.json +23 -0
- package/data/formatting/nextjs.json +23 -0
- package/data/formatting/react.json +71 -0
- package/data/formatting/shadcn.json +61 -0
- package/data/formatting/shell.json +103 -19
- package/data/formatting/tailwindcss.json +48 -0
- package/data/hover/angular.json +455 -0
- package/data/hover/css.json +300 -0
- package/data/hover/nestjs.json +296 -0
- package/data/hover/nextjs.json +305 -0
- package/data/hover/react.json +173 -0
- package/data/hover/redis-cli.json +1 -1
- package/data/hover/shadcn.json +450 -0
- package/data/hover/shell.json +684 -75
- package/data/hover/tailwindcss.json +968 -0
- package/data/implementation/angular.json +22 -0
- package/data/implementation/css.json +65 -0
- package/data/implementation/nestjs.json +24 -0
- package/data/implementation/nextjs.json +137 -0
- package/data/implementation/react.json +125 -0
- package/data/implementation/shadcn.json +89 -0
- package/data/implementation/shell.json +59 -3
- package/data/implementation/tailwindcss.json +59 -0
- package/data/inlayHints/angular.json +24 -0
- package/data/inlayHints/css.json +87 -0
- package/data/inlayHints/nestjs.json +24 -0
- package/data/inlayHints/nextjs.json +143 -0
- package/data/inlayHints/react.json +177 -0
- package/data/inlayHints/shadcn.json +109 -0
- package/data/inlayHints/shell.json +223 -35
- package/data/inlayHints/tailwindcss.json +111 -0
- package/data/inlineCompletions/angular.json +135 -0
- package/data/inlineCompletions/css.json +125 -0
- package/data/inlineCompletions/javascript.json +12 -0
- package/data/inlineCompletions/nestjs.json +25 -0
- package/data/inlineCompletions/nextjs.json +179 -0
- package/data/inlineCompletions/react.json +203 -0
- package/data/inlineCompletions/shadcn.json +115 -0
- package/data/inlineCompletions/shell.json +185 -35
- package/data/inlineCompletions/tailwindcss.json +411 -0
- package/data/inlineCompletions/typescript.json +12 -0
- package/data/linkedEditingRange/angular.json +23 -0
- package/data/linkedEditingRange/css.json +40 -0
- package/data/linkedEditingRange/nestjs.json +10 -0
- package/data/linkedEditingRange/nextjs.json +11 -0
- package/data/linkedEditingRange/react.json +75 -0
- package/data/linkedEditingRange/shadcn.json +23 -0
- package/data/linkedEditingRange/shell.json +25 -25
- package/data/linkedEditingRange/tailwindcss.json +30 -0
- package/data/links/angular.json +95 -0
- package/data/links/css.json +55 -0
- package/data/links/nestjs.json +130 -0
- package/data/links/nextjs.json +91 -0
- package/data/links/react.json +75 -0
- package/data/links/shadcn.json +98 -0
- package/data/links/shell.json +56 -0
- package/data/links/tailwindcss.json +65 -0
- package/data/manifest.json +399 -150
- package/data/onTypeFormatting/angular.json +14 -0
- package/data/onTypeFormatting/css.json +82 -0
- package/data/onTypeFormatting/nestjs.json +16 -0
- package/data/onTypeFormatting/nextjs.json +17 -0
- package/data/onTypeFormatting/react.json +127 -0
- package/data/onTypeFormatting/shadcn.json +54 -0
- package/data/onTypeFormatting/shell.json +72 -68
- package/data/onTypeFormatting/tailwindcss.json +63 -0
- package/data/rangeSemanticTokens/angular.json +140 -0
- package/data/rangeSemanticTokens/css.json +125 -0
- package/data/rangeSemanticTokens/nestjs.json +27 -0
- package/data/rangeSemanticTokens/nextjs.json +28 -0
- package/data/rangeSemanticTokens/react.json +216 -0
- package/data/rangeSemanticTokens/shadcn.json +140 -0
- package/data/rangeSemanticTokens/shell.json +247 -69
- package/data/rangeSemanticTokens/tailwindcss.json +186 -0
- package/data/references/angular.json +26 -0
- package/data/references/css.json +65 -0
- package/data/references/nestjs.json +24 -0
- package/data/references/nextjs.json +178 -0
- package/data/references/react.json +192 -0
- package/data/references/shadcn.json +101 -0
- package/data/references/shell.json +323 -92
- package/data/references/tailwindcss.json +125 -0
- package/data/rename/angular.json +131 -0
- package/data/rename/css.json +91 -0
- package/data/rename/nestjs.json +32 -0
- package/data/rename/nextjs.json +31 -0
- package/data/rename/react.json +88 -0
- package/data/rename/shadcn.json +79 -0
- package/data/rename/shell.json +101 -31
- package/data/rename/tailwindcss.json +58 -0
- package/data/selectionRange/angular.json +95 -0
- package/data/selectionRange/css.json +55 -0
- package/data/selectionRange/nestjs.json +21 -0
- package/data/selectionRange/nextjs.json +22 -0
- package/data/selectionRange/react.json +87 -0
- package/data/selectionRange/shadcn.json +89 -0
- package/data/selectionRange/shell.json +65 -35
- package/data/selectionRange/tailwindcss.json +35 -0
- package/data/semanticTokens/angular.json +198 -0
- package/data/semanticTokens/css.json +107 -0
- package/data/semanticTokens/nestjs.json +35 -0
- package/data/semanticTokens/nextjs.json +38 -0
- package/data/semanticTokens/react.json +215 -0
- package/data/semanticTokens/shadcn.json +180 -0
- package/data/semanticTokens/shell.json +238 -65
- package/data/semanticTokens/tailwindcss.json +161 -0
- package/data/signatureHelp/angular.json +182 -0
- package/data/signatureHelp/css.json +137 -0
- package/data/signatureHelp/nestjs.json +128 -0
- package/data/signatureHelp/nextjs.json +127 -0
- package/data/signatureHelp/react.json +281 -0
- package/data/signatureHelp/shadcn.json +237 -0
- package/data/signatureHelp/shell.json +797 -104
- package/data/signatureHelp/tailwindcss.json +64 -0
- package/data/typeDefinition/angular.json +362 -0
- package/data/typeDefinition/css.json +53 -0
- package/data/typeDefinition/nestjs.json +334 -0
- package/data/typeDefinition/nextjs.json +285 -0
- package/data/typeDefinition/react.json +236 -0
- package/data/typeDefinition/shadcn.json +292 -0
- package/data/typeDefinition/shell.json +104 -40
- package/data/typeDefinition/tailwindcss.json +47 -0
- package/package.json +1 -1
- package/data/codeActions/bash.json +0 -169
- package/data/codeActions/zsh.json +0 -49
- package/data/codeLens/bash.json +0 -75
- package/data/codeLens/zsh.json +0 -19
- package/data/color/bash.json +0 -100
- package/data/color/zsh.json +0 -80
- package/data/commands/bash.json +0 -102
- package/data/commands/zsh.json +0 -166
- package/data/completion/bash.json +0 -1184
- package/data/completion/zsh.json +0 -973
- package/data/declaration/bash.json +0 -301
- package/data/declaration/zsh.json +0 -205
- package/data/definition/bash.json +0 -565
- package/data/definition/zsh.json +0 -350
- package/data/documentHighlight/bash.json +0 -393
- package/data/documentHighlight/zsh.json +0 -266
- package/data/documentRangeFormatting/bash.json +0 -41
- package/data/documentRangeFormatting/zsh.json +0 -59
- package/data/documentSymbol/bash.json +0 -124
- package/data/documentSymbol/zsh.json +0 -26
- package/data/foldingRange/bash.json +0 -76
- package/data/foldingRange/zsh.json +0 -46
- package/data/formatting/bash.json +0 -88
- package/data/formatting/zsh.json +0 -28
- package/data/hover/bash.json +0 -579
- package/data/hover/zsh.json +0 -96
- package/data/implementation/bash.json +0 -44
- package/data/implementation/zsh.json +0 -41
- package/data/inlayHints/bash.json +0 -207
- package/data/inlayHints/zsh.json +0 -43
- package/data/inlineCompletions/bash.json +0 -155
- package/data/inlineCompletions/zsh.json +0 -17
- package/data/linkedEditingRange/bash.json +0 -25
- package/data/linkedEditingRange/zsh.json +0 -25
- package/data/links/bash.json +0 -56
- package/data/links/zsh.json +0 -15
- package/data/onTypeFormatting/bash.json +0 -68
- package/data/onTypeFormatting/zsh.json +0 -68
- package/data/rangeSemanticTokens/bash.json +0 -90
- package/data/rangeSemanticTokens/zsh.json +0 -76
- package/data/references/bash.json +0 -221
- package/data/references/zsh.json +0 -166
- package/data/rename/bash.json +0 -37
- package/data/rename/zsh.json +0 -31
- package/data/selectionRange/bash.json +0 -35
- package/data/selectionRange/zsh.json +0 -35
- package/data/semanticTokens/bash.json +0 -71
- package/data/semanticTokens/zsh.json +0 -71
- package/data/signatureHelp/bash.json +0 -111
- package/data/signatureHelp/zsh.json +0 -118
- package/data/typeDefinition/bash.json +0 -95
- package/data/typeDefinition/zsh.json +0 -40
|
@@ -0,0 +1,1319 @@
|
|
|
1
|
+
{
|
|
2
|
+
"language": "react",
|
|
3
|
+
"completions": [
|
|
4
|
+
{
|
|
5
|
+
"label": "rfc",
|
|
6
|
+
"kind": 28,
|
|
7
|
+
"detail": "React Functional Component",
|
|
8
|
+
"documentation": { "value": "Creates a new React functional component with props interface and export." },
|
|
9
|
+
"insertText": "import React from 'react';\n\ninterface ${1:ComponentName}Props {\n ${2:// props}\n}\n\nexport const ${1:ComponentName}: React.FC<${1:ComponentName}Props> = ({ ${3:} }) => {\n return (\n <div>\n ${0}\n </div>\n );\n};\n\nexport default ${1:ComponentName};",
|
|
10
|
+
"insertTextRules": 4,
|
|
11
|
+
"sortText": "00_rfc"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"label": "rafc",
|
|
15
|
+
"kind": 28,
|
|
16
|
+
"detail": "React Arrow Function Component",
|
|
17
|
+
"documentation": { "value": "Creates a React arrow function component with default export." },
|
|
18
|
+
"insertText": "const ${1:ComponentName} = () => {\n return (\n <div>\n ${0}\n </div>\n );\n};\n\nexport default ${1:ComponentName};",
|
|
19
|
+
"insertTextRules": 4,
|
|
20
|
+
"sortText": "00_rafc"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"label": "rmemo",
|
|
24
|
+
"kind": 28,
|
|
25
|
+
"detail": "React.memo Component",
|
|
26
|
+
"documentation": { "value": "Creates a memoized React component using React.memo for performance optimization." },
|
|
27
|
+
"insertText": "import React from 'react';\n\ninterface ${1:ComponentName}Props {\n ${2:// props}\n}\n\nexport const ${1:ComponentName} = React.memo<${1:ComponentName}Props>(({ ${3:} }) => {\n return (\n <div>\n ${0}\n </div>\n );\n});\n\n${1:ComponentName}.displayName = '${1:ComponentName}';",
|
|
28
|
+
"insertTextRules": 4,
|
|
29
|
+
"sortText": "00_rmemo"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"label": "rfref",
|
|
33
|
+
"kind": 28,
|
|
34
|
+
"detail": "forwardRef Component",
|
|
35
|
+
"documentation": { "value": "Creates a React component with forwardRef for passing refs to child elements." },
|
|
36
|
+
"insertText": "import React, { forwardRef } from 'react';\n\ninterface ${1:ComponentName}Props {\n ${2:// props}\n}\n\nexport const ${1:ComponentName} = forwardRef<${3:HTMLDivElement}, ${1:ComponentName}Props>(\n ({ ${4:} }, ref) => {\n return (\n <div ref={ref}>\n ${0}\n </div>\n );\n }\n);\n\n${1:ComponentName}.displayName = '${1:ComponentName}';",
|
|
37
|
+
"insertTextRules": 4,
|
|
38
|
+
"sortText": "00_rfref"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"label": "rctxp",
|
|
42
|
+
"kind": 28,
|
|
43
|
+
"detail": "Context Provider Component",
|
|
44
|
+
"documentation": { "value": "Creates a React Context with Provider component and custom hook." },
|
|
45
|
+
"insertText": "import React, { createContext, useContext, useState } from 'react';\n\ninterface ${1:Name}ContextType {\n ${2:value}: ${3:string};\n ${4:setValue}: (val: ${3:string}) => void;\n}\n\nconst ${1:Name}Context = createContext<${1:Name}ContextType | undefined>(undefined);\n\nexport const ${1:Name}Provider: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const [${2:value}, ${4:setValue}] = useState<${3:string}>(${5:''});\n\n return (\n <${1:Name}Context.Provider value={{ ${2:value}, ${4:setValue} }}>\n {children}\n </${1:Name}Context.Provider>\n );\n};\n\nexport const use${1:Name} = () => {\n const context = useContext(${1:Name}Context);\n if (!context) throw new Error('use${1:Name} must be used within ${1:Name}Provider');\n return context;\n};",
|
|
46
|
+
"insertTextRules": 4,
|
|
47
|
+
"sortText": "00_rctxp"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"label": "rcustomhook",
|
|
51
|
+
"kind": 28,
|
|
52
|
+
"detail": "Custom Hook",
|
|
53
|
+
"documentation": { "value": "Creates a custom React hook with state management." },
|
|
54
|
+
"insertText": "import { useState, useEffect } from 'react';\n\nexport const use${1:HookName} = (${2:initialValue}: ${3:any}) => {\n const [${4:state}, set${4/(.*)/${1:/capitalize}/}] = useState<${3:any}>(${2:initialValue});\n\n useEffect(() => {\n ${5:// effect logic}\n return () => {\n ${6:// cleanup}\n };\n }, [${7:}]);\n\n return { ${4:state}, set${4/(.*)/${1:/capitalize}/} };\n};",
|
|
55
|
+
"insertTextRules": 4,
|
|
56
|
+
"sortText": "00_rcustomhook"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"label": "ruecleanup",
|
|
60
|
+
"kind": 28,
|
|
61
|
+
"detail": "useEffect with Cleanup",
|
|
62
|
+
"documentation": { "value": "Creates a useEffect hook with cleanup function for subscriptions and timers." },
|
|
63
|
+
"insertText": "useEffect(() => {\n ${1:// setup}\n const ${2:subscription} = ${3:subscribe()};\n\n return () => {\n ${2:subscription}.${4:unsubscribe}();\n };\n}, [${5:}]);",
|
|
64
|
+
"insertTextRules": 4,
|
|
65
|
+
"sortText": "00_ruecleanup"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"label": "rreducer",
|
|
69
|
+
"kind": 28,
|
|
70
|
+
"detail": "useReducer with Types",
|
|
71
|
+
"documentation": { "value": "Creates a typed useReducer with action types and reducer function." },
|
|
72
|
+
"insertText": "type ${1:State} = {\n ${2:count}: number;\n};\n\ntype ${1:State}Action =\n | { type: '${3:INCREMENT}' }\n | { type: '${4:DECREMENT}' }\n | { type: '${5:RESET}'; payload: number };\n\nconst ${6:reducer} = (state: ${1:State}, action: ${1:State}Action): ${1:State} => {\n switch (action.type) {\n case '${3:INCREMENT}':\n return { ...state, ${2:count}: state.${2:count} + 1 };\n case '${4:DECREMENT}':\n return { ...state, ${2:count}: state.${2:count} - 1 };\n case '${5:RESET}':\n return { ...state, ${2:count}: action.payload };\n default:\n return state;\n }\n};\n\nconst [state, dispatch] = useReducer(${6:reducer}, { ${2:count}: ${7:0} });",
|
|
73
|
+
"insertTextRules": 4,
|
|
74
|
+
"sortText": "00_rreducer"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"label": "rerrboundary",
|
|
78
|
+
"kind": 28,
|
|
79
|
+
"detail": "Error Boundary Class Component",
|
|
80
|
+
"documentation": { "value": "Creates an Error Boundary class component for catching rendering errors." },
|
|
81
|
+
"insertText": "import React, { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface ErrorBoundaryProps {\n children: ReactNode;\n fallback?: ReactNode;\n}\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n error: Error | null;\n}\n\nclass ${1:ErrorBoundary} extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n console.error('Error caught by boundary:', error, errorInfo);\n }\n\n render() {\n if (this.state.hasError) {\n return this.props.fallback || <h1>Something went wrong.</h1>;\n }\n return this.props.children;\n }\n}\n\nexport default ${1:ErrorBoundary};",
|
|
82
|
+
"insertTextRules": 4,
|
|
83
|
+
"sortText": "00_rerrboundary"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"label": "rlazy",
|
|
87
|
+
"kind": 28,
|
|
88
|
+
"detail": "Lazy Component Import",
|
|
89
|
+
"documentation": { "value": "Creates a lazily loaded component with React.lazy and Suspense." },
|
|
90
|
+
"insertText": "const ${1:LazyComponent} = React.lazy(() => import('${2:./components/${1:LazyComponent}}'));\n\n// Usage:\n// <Suspense fallback={<${3:Loading} />}>\n// <${1:LazyComponent} />\n// </Suspense>",
|
|
91
|
+
"insertTextRules": 4,
|
|
92
|
+
"sortText": "00_rlazy"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"label": "rsuspense",
|
|
96
|
+
"kind": 28,
|
|
97
|
+
"detail": "Suspense Boundary",
|
|
98
|
+
"documentation": { "value": "Wraps components in a Suspense boundary with a fallback UI." },
|
|
99
|
+
"insertText": "<React.Suspense fallback={<${1:div}>Loading...</${1:div}>}>\n ${0}\n</React.Suspense>",
|
|
100
|
+
"insertTextRules": 4,
|
|
101
|
+
"sortText": "00_rsuspense"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"label": "rportal",
|
|
105
|
+
"kind": 28,
|
|
106
|
+
"detail": "React Portal",
|
|
107
|
+
"documentation": { "value": "Creates a React Portal for rendering children into a different DOM subtree." },
|
|
108
|
+
"insertText": "import { createPortal } from 'react-dom';\n\nconst ${1:Portal}: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const portalRoot = document.getElementById('${2:portal-root}');\n if (!portalRoot) return null;\n return createPortal(children, portalRoot);\n};",
|
|
109
|
+
"insertTextRules": 4,
|
|
110
|
+
"sortText": "00_rportal"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"label": "rfrag",
|
|
114
|
+
"kind": 28,
|
|
115
|
+
"detail": "React Fragment",
|
|
116
|
+
"documentation": { "value": "Wraps content in a React Fragment without adding extra DOM nodes." },
|
|
117
|
+
"insertText": "<React.Fragment>\n ${0}\n</React.Fragment>",
|
|
118
|
+
"insertTextRules": 4,
|
|
119
|
+
"sortText": "00_rfrag"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"label": "rcinput",
|
|
123
|
+
"kind": 28,
|
|
124
|
+
"detail": "Controlled Input Component",
|
|
125
|
+
"documentation": { "value": "Creates a controlled input with state binding and onChange handler." },
|
|
126
|
+
"insertText": "const [${1:value}, set${1/(.*)/${1:/capitalize}/}] = useState('');\n\nconst handle${1/(.*)/${1:/capitalize}/}Change = (e: React.ChangeEvent<HTMLInputElement>) => {\n set${1/(.*)/${1:/capitalize}/}(e.target.value);\n};\n\n// JSX:\n// <input value={${1:value}} onChange={handle${1/(.*)/${1:/capitalize}/}Change} />",
|
|
127
|
+
"insertTextRules": 4,
|
|
128
|
+
"sortText": "00_rcinput"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"label": "rformhandler",
|
|
132
|
+
"kind": 28,
|
|
133
|
+
"detail": "Form Handler",
|
|
134
|
+
"documentation": { "value": "Creates a form with submit handler and state management." },
|
|
135
|
+
"insertText": "const [formData, setFormData] = useState({\n ${1:email}: '',\n ${2:password}: ''\n});\n\nconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const { name, value } = e.target;\n setFormData(prev => ({ ...prev, [name]: value }));\n};\n\nconst handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n ${0:// submit logic}\n};\n\n// <form onSubmit={handleSubmit}>\n// <input name=\"${1:email}\" value={formData.${1:email}} onChange={handleChange} />\n// </form>",
|
|
136
|
+
"insertTextRules": 4,
|
|
137
|
+
"sortText": "00_rformhandler"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"label": "rcondrender",
|
|
141
|
+
"kind": 28,
|
|
142
|
+
"detail": "Conditional Rendering",
|
|
143
|
+
"documentation": { "value": "Pattern for conditional rendering with ternary and logical AND." },
|
|
144
|
+
"insertText": "{${1:condition} ? (\n <${2:div}>${3:Truthy content}</${2:div}>\n) : (\n <${4:div}>${5:Falsy content}</${4:div}>\n)}",
|
|
145
|
+
"insertTextRules": 4,
|
|
146
|
+
"sortText": "00_rcondrender"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"label": "rlistmap",
|
|
150
|
+
"kind": 28,
|
|
151
|
+
"detail": "List Rendering with Key",
|
|
152
|
+
"documentation": { "value": "Maps over an array to render a list with unique keys." },
|
|
153
|
+
"insertText": "{${1:items}.map((${2:item}) => (\n <${3:div} key={${2:item}.${4:id}}>\n {${2:item}.${5:name}}\n </${3:div}>\n))}",
|
|
154
|
+
"insertTextRules": 4,
|
|
155
|
+
"sortText": "00_rlistmap"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"label": "rhoc",
|
|
159
|
+
"kind": 28,
|
|
160
|
+
"detail": "Higher-Order Component Pattern",
|
|
161
|
+
"documentation": { "value": "Creates a Higher-Order Component (HOC) that wraps a component with additional props or logic." },
|
|
162
|
+
"insertText": "import React, { ComponentType } from 'react';\n\ninterface With${1:Feature}Props {\n ${2:featureProp}: ${3:string};\n}\n\nexport const with${1:Feature} = <P extends object>(\n WrappedComponent: ComponentType<P & With${1:Feature}Props>\n) => {\n const WithFeatureComponent = (props: P) => {\n const ${2:featureProp} = ${4:'value'};\n return <WrappedComponent {...props} ${2:featureProp}={${2:featureProp}} />;\n };\n WithFeatureComponent.displayName = \\`with${1:Feature}(\\${WrappedComponent.displayName || WrappedComponent.name})\\`;\n return WithFeatureComponent;\n};",
|
|
163
|
+
"insertTextRules": 4,
|
|
164
|
+
"sortText": "00_rhoc"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"label": "rrenderprops",
|
|
168
|
+
"kind": 28,
|
|
169
|
+
"detail": "Render Props Pattern",
|
|
170
|
+
"documentation": { "value": "Creates a component using the render props pattern for sharing logic." },
|
|
171
|
+
"insertText": "interface ${1:DataProvider}Props {\n render: (data: { ${2:value}: ${3:string}; ${4:loading}: boolean }) => React.ReactNode;\n}\n\nconst ${1:DataProvider}: React.FC<${1:DataProvider}Props> = ({ render }) => {\n const [${2:value}, set${2/(.*)/${1:/capitalize}/}] = useState<${3:string}>('');\n const [${4:loading}, setLoading] = useState(true);\n\n useEffect(() => {\n ${5:// fetch data}\n setLoading(false);\n }, []);\n\n return <>{render({ ${2:value}, ${4:loading} })}</>;\n};",
|
|
172
|
+
"insertTextRules": 4,
|
|
173
|
+
"sortText": "00_rrenderprops"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"label": "rcompound",
|
|
177
|
+
"kind": 28,
|
|
178
|
+
"detail": "Compound Component Pattern",
|
|
179
|
+
"documentation": { "value": "Creates a compound component with shared context between parent and children." },
|
|
180
|
+
"insertText": "import React, { createContext, useContext, useState } from 'react';\n\ninterface ${1:Tabs}ContextType {\n activeTab: string;\n setActiveTab: (tab: string) => void;\n}\n\nconst ${1:Tabs}Context = createContext<${1:Tabs}ContextType | undefined>(undefined);\n\nconst ${1:Tabs}: React.FC<{ children: React.ReactNode; defaultTab: string }> & {\n Tab: typeof Tab;\n Panel: typeof Panel;\n} = ({ children, defaultTab }) => {\n const [activeTab, setActiveTab] = useState(defaultTab);\n return (\n <${1:Tabs}Context.Provider value={{ activeTab, setActiveTab }}>\n {children}\n </${1:Tabs}Context.Provider>\n );\n};\n\nconst Tab: React.FC<{ name: string; children: React.ReactNode }> = ({ name, children }) => {\n const ctx = useContext(${1:Tabs}Context)!;\n return <button onClick={() => ctx.setActiveTab(name)}>{children}</button>;\n};\n\nconst Panel: React.FC<{ name: string; children: React.ReactNode }> = ({ name, children }) => {\n const ctx = useContext(${1:Tabs}Context)!;\n return ctx.activeTab === name ? <>{children}</> : null;\n};\n\n${1:Tabs}.Tab = Tab;\n${1:Tabs}.Panel = Panel;\n\nexport default ${1:Tabs};",
|
|
181
|
+
"insertTextRules": 4,
|
|
182
|
+
"sortText": "00_rcompound"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"label": "rcc",
|
|
186
|
+
"kind": 28,
|
|
187
|
+
"detail": "Class Component (Legacy)",
|
|
188
|
+
"documentation": { "value": "Creates a legacy class-based React component with state and lifecycle methods." },
|
|
189
|
+
"insertText": "import React, { Component } from 'react';\n\ninterface ${1:ComponentName}Props {\n ${2:// props}\n}\n\ninterface ${1:ComponentName}State {\n ${3:// state}\n}\n\nclass ${1:ComponentName} extends Component<${1:ComponentName}Props, ${1:ComponentName}State> {\n state: ${1:ComponentName}State = {\n ${4}\n };\n\n componentDidMount() {\n ${5}\n }\n\n render() {\n return (\n <div>\n ${0}\n </div>\n );\n }\n}\n\nexport default ${1:ComponentName};",
|
|
190
|
+
"insertTextRules": 4,
|
|
191
|
+
"sortText": "00_rcc"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"label": "rpropsdestructure",
|
|
195
|
+
"kind": 28,
|
|
196
|
+
"detail": "Component with Props Destructuring",
|
|
197
|
+
"documentation": { "value": "Creates a functional component with inline props destructuring and default values." },
|
|
198
|
+
"insertText": "interface ${1:ComponentName}Props {\n ${2:title}: string;\n ${3:count}?: number;\n ${4:children}?: React.ReactNode;\n}\n\nexport const ${1:ComponentName} = ({\n ${2:title},\n ${3:count} = ${5:0},\n ${4:children}\n}: ${1:ComponentName}Props) => {\n return (\n <div>\n <h2>{${2:title}}</h2>\n ${0}\n {${4:children}}\n </div>\n );\n};",
|
|
199
|
+
"insertTextRules": 4,
|
|
200
|
+
"sortText": "00_rpropsdestructure"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"label": "useState",
|
|
204
|
+
"kind": 1,
|
|
205
|
+
"detail": "React Hook: useState",
|
|
206
|
+
"documentation": { "value": "Declares a state variable. Returns a stateful value and a function to update it.\n\n```jsx\nconst [state, setState] = useState(initialState);\n```" },
|
|
207
|
+
"insertText": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState${2:<${3:type}>}(${4:initialValue});",
|
|
208
|
+
"insertTextRules": 4,
|
|
209
|
+
"sortText": "02_useState"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"label": "useEffect",
|
|
213
|
+
"kind": 1,
|
|
214
|
+
"detail": "React Hook: useEffect",
|
|
215
|
+
"documentation": { "value": "Accepts a function that contains imperative, possibly effectful code. Runs after render.\n\n```jsx\nuseEffect(() => { /* effect */ return () => { /* cleanup */ }; }, [deps]);\n```" },
|
|
216
|
+
"insertText": "useEffect(() => {\n ${1:// effect}\n return () => {\n ${2:// cleanup}\n };\n}, [${3:}]);",
|
|
217
|
+
"insertTextRules": 4,
|
|
218
|
+
"sortText": "02_useEffect"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"label": "useContext",
|
|
222
|
+
"kind": 1,
|
|
223
|
+
"detail": "React Hook: useContext",
|
|
224
|
+
"documentation": { "value": "Accepts a context object and returns the current context value.\n\n```jsx\nconst value = useContext(MyContext);\n```" },
|
|
225
|
+
"insertText": "const ${1:value} = useContext(${2:MyContext});",
|
|
226
|
+
"insertTextRules": 4,
|
|
227
|
+
"sortText": "02_useContext"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"label": "useReducer",
|
|
231
|
+
"kind": 1,
|
|
232
|
+
"detail": "React Hook: useReducer",
|
|
233
|
+
"documentation": { "value": "An alternative to useState for complex state logic. Accepts a reducer and initial state.\n\n```jsx\nconst [state, dispatch] = useReducer(reducer, initialState);\n```" },
|
|
234
|
+
"insertText": "const [${1:state}, dispatch] = useReducer(${2:reducer}, ${3:initialState});",
|
|
235
|
+
"insertTextRules": 4,
|
|
236
|
+
"sortText": "02_useReducer"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"label": "useMemo",
|
|
240
|
+
"kind": 1,
|
|
241
|
+
"detail": "React Hook: useMemo",
|
|
242
|
+
"documentation": { "value": "Returns a memoized value. Only recomputes when dependencies change.\n\n```jsx\nconst memoizedValue = useMemo(() => computeExpensive(a, b), [a, b]);\n```" },
|
|
243
|
+
"insertText": "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue(${3:a, b})}, [${3:a, b}]);",
|
|
244
|
+
"insertTextRules": 4,
|
|
245
|
+
"sortText": "02_useMemo"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"label": "useCallback",
|
|
249
|
+
"kind": 1,
|
|
250
|
+
"detail": "React Hook: useCallback",
|
|
251
|
+
"documentation": { "value": "Returns a memoized callback function. Only changes when dependencies change.\n\n```jsx\nconst memoizedFn = useCallback(() => { doSomething(a, b); }, [a, b]);\n```" },
|
|
252
|
+
"insertText": "const ${1:memoizedCallback} = useCallback(${2:(${3:}) => {\n ${4:// callback logic}\n}}, [${5:}]);",
|
|
253
|
+
"insertTextRules": 4,
|
|
254
|
+
"sortText": "02_useCallback"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"label": "useRef",
|
|
258
|
+
"kind": 1,
|
|
259
|
+
"detail": "React Hook: useRef",
|
|
260
|
+
"documentation": { "value": "Returns a mutable ref object whose .current property is initialized to the passed argument.\n\n```jsx\nconst ref = useRef(initialValue);\n```" },
|
|
261
|
+
"insertText": "const ${1:ref} = useRef<${2:HTMLDivElement}>(${3:null});",
|
|
262
|
+
"insertTextRules": 4,
|
|
263
|
+
"sortText": "02_useRef"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"label": "useId",
|
|
267
|
+
"kind": 1,
|
|
268
|
+
"detail": "React Hook: useId",
|
|
269
|
+
"documentation": { "value": "Generates a unique ID for accessibility attributes. Stable across server and client.\n\n```jsx\nconst id = useId();\n```" },
|
|
270
|
+
"insertText": "const ${1:id} = useId();",
|
|
271
|
+
"insertTextRules": 4,
|
|
272
|
+
"sortText": "02_useId"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"label": "useTransition",
|
|
276
|
+
"kind": 1,
|
|
277
|
+
"detail": "React Hook: useTransition",
|
|
278
|
+
"documentation": { "value": "Returns a stateful value for the pending state of a transition and a function to start it.\n\n```jsx\nconst [isPending, startTransition] = useTransition();\n```" },
|
|
279
|
+
"insertText": "const [isPending, startTransition] = useTransition();",
|
|
280
|
+
"insertTextRules": 4,
|
|
281
|
+
"sortText": "02_useTransition"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"label": "useDeferredValue",
|
|
285
|
+
"kind": 1,
|
|
286
|
+
"detail": "React Hook: useDeferredValue",
|
|
287
|
+
"documentation": { "value": "Accepts a value and returns a deferred version that may lag behind. Useful for expensive re-renders.\n\n```jsx\nconst deferredValue = useDeferredValue(value);\n```" },
|
|
288
|
+
"insertText": "const ${1:deferredValue} = useDeferredValue(${2:value});",
|
|
289
|
+
"insertTextRules": 4,
|
|
290
|
+
"sortText": "02_useDeferredValue"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"label": "useSyncExternalStore",
|
|
294
|
+
"kind": 1,
|
|
295
|
+
"detail": "React Hook: useSyncExternalStore",
|
|
296
|
+
"documentation": { "value": "Subscribes to an external store. Recommended for integrating with non-React state.\n\n```jsx\nconst snapshot = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot?);\n```" },
|
|
297
|
+
"insertText": "const ${1:snapshot} = useSyncExternalStore(\n ${2:subscribe},\n ${3:getSnapshot},\n ${4:getServerSnapshot}\n);",
|
|
298
|
+
"insertTextRules": 4,
|
|
299
|
+
"sortText": "02_useSyncExternalStore"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"label": "useInsertionEffect",
|
|
303
|
+
"kind": 1,
|
|
304
|
+
"detail": "React Hook: useInsertionEffect",
|
|
305
|
+
"documentation": { "value": "Fires synchronously before all DOM mutations. Use for injecting styles into the DOM before layout effects.\n\n```jsx\nuseInsertionEffect(() => { /* inject styles */ }, [deps]);\n```" },
|
|
306
|
+
"insertText": "useInsertionEffect(() => {\n ${1:// inject styles before DOM mutations}\n}, [${2:}]);",
|
|
307
|
+
"insertTextRules": 4,
|
|
308
|
+
"sortText": "02_useInsertionEffect"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"label": "useLayoutEffect",
|
|
312
|
+
"kind": 1,
|
|
313
|
+
"detail": "React Hook: useLayoutEffect",
|
|
314
|
+
"documentation": { "value": "Fires synchronously after all DOM mutations. Use for reading layout and synchronously re-rendering.\n\n```jsx\nuseLayoutEffect(() => { /* read DOM */ }, [deps]);\n```" },
|
|
315
|
+
"insertText": "useLayoutEffect(() => {\n ${1:// read layout / DOM measurements}\n return () => {\n ${2:// cleanup}\n };\n}, [${3:}]);",
|
|
316
|
+
"insertTextRules": 4,
|
|
317
|
+
"sortText": "02_useLayoutEffect"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"label": "useImperativeHandle",
|
|
321
|
+
"kind": 1,
|
|
322
|
+
"detail": "React Hook: useImperativeHandle",
|
|
323
|
+
"documentation": { "value": "Customizes the instance value that is exposed to parent components when using ref.\n\n```jsx\nuseImperativeHandle(ref, () => ({ focus() { ... } }), [deps]);\n```" },
|
|
324
|
+
"insertText": "useImperativeHandle(${1:ref}, () => ({\n ${2:focus}() {\n ${3:// imperative method}\n }\n}), [${4:}]);",
|
|
325
|
+
"insertTextRules": 4,
|
|
326
|
+
"sortText": "02_useImperativeHandle"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"label": "useDebugValue",
|
|
330
|
+
"kind": 1,
|
|
331
|
+
"detail": "React Hook: useDebugValue",
|
|
332
|
+
"documentation": { "value": "Displays a label in React DevTools for custom hooks.\n\n```jsx\nuseDebugValue(value, formatFn?);\n```" },
|
|
333
|
+
"insertText": "useDebugValue(${1:value}${2:, (val) => ${3:formatValue(val)}});",
|
|
334
|
+
"insertTextRules": 4,
|
|
335
|
+
"sortText": "02_useDebugValue"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"label": "useOptimistic",
|
|
339
|
+
"kind": 1,
|
|
340
|
+
"detail": "React Hook: useOptimistic",
|
|
341
|
+
"documentation": { "value": "Allows optimistic UI updates while async actions are in progress.\n\n```jsx\nconst [optimisticState, addOptimistic] = useOptimistic(state, updateFn);\n```" },
|
|
342
|
+
"insertText": "const [${1:optimisticState}, ${2:addOptimistic}] = useOptimistic(\n ${3:state},\n (${4:currentState}, ${5:optimisticValue}) => {\n return ${6:/* merged state */};\n }\n);",
|
|
343
|
+
"insertTextRules": 4,
|
|
344
|
+
"sortText": "02_useOptimistic"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"label": "useFormStatus",
|
|
348
|
+
"kind": 1,
|
|
349
|
+
"detail": "React Hook: useFormStatus",
|
|
350
|
+
"documentation": { "value": "Gives status information of the last form submission. Must be called from a component rendered inside a <form>.\n\n```jsx\nconst { pending, data, method, action } = useFormStatus();\n```" },
|
|
351
|
+
"insertText": "const { pending, data, method, action } = useFormStatus();",
|
|
352
|
+
"insertTextRules": 4,
|
|
353
|
+
"sortText": "02_useFormStatus"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"label": "useActionState",
|
|
357
|
+
"kind": 1,
|
|
358
|
+
"detail": "React Hook: useActionState",
|
|
359
|
+
"documentation": { "value": "Allows you to update state based on the result of a form action.\n\n```jsx\nconst [state, formAction] = useActionState(fn, initialState, permalink?);\n```" },
|
|
360
|
+
"insertText": "const [${1:state}, ${2:formAction}] = useActionState(\n async (${3:previousState}, ${4:formData}) => {\n ${5:// action logic}\n return ${6:newState};\n },\n ${7:initialState}\n);",
|
|
361
|
+
"insertTextRules": 4,
|
|
362
|
+
"sortText": "02_useActionState"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"label": "use",
|
|
366
|
+
"kind": 1,
|
|
367
|
+
"detail": "React Hook: use",
|
|
368
|
+
"documentation": { "value": "Reads the value of a resource like a Promise or context. Can be called conditionally unlike other hooks.\n\n```jsx\nconst value = use(resource);\n```" },
|
|
369
|
+
"insertText": "const ${1:value} = use(${2:resource});",
|
|
370
|
+
"insertTextRules": 4,
|
|
371
|
+
"sortText": "02_use"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"label": "createElement",
|
|
375
|
+
"kind": 1,
|
|
376
|
+
"detail": "React.createElement",
|
|
377
|
+
"documentation": { "value": "Create a React element. JSX is compiled to createElement calls.\n\n```jsx\nReact.createElement(type, props, ...children)\n```" },
|
|
378
|
+
"insertText": "React.createElement(${1:'div'}, ${2:{ className: '${3:}' }}, ${4:children})",
|
|
379
|
+
"insertTextRules": 4,
|
|
380
|
+
"sortText": "02_createElement"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"label": "cloneElement",
|
|
384
|
+
"kind": 1,
|
|
385
|
+
"detail": "React.cloneElement",
|
|
386
|
+
"documentation": { "value": "Clone and return a new React element using element as the starting point with new props merged in.\n\n```jsx\nReact.cloneElement(element, props, ...children)\n```" },
|
|
387
|
+
"insertText": "React.cloneElement(${1:element}, ${2:{ ...newProps }})",
|
|
388
|
+
"insertTextRules": 4,
|
|
389
|
+
"sortText": "02_cloneElement"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"label": "createContext",
|
|
393
|
+
"kind": 1,
|
|
394
|
+
"detail": "React.createContext",
|
|
395
|
+
"documentation": { "value": "Creates a Context object for passing data through the component tree without prop drilling.\n\n```jsx\nconst MyContext = createContext(defaultValue);\n```" },
|
|
396
|
+
"insertText": "const ${1:MyContext} = createContext<${2:ContextType}>(${3:defaultValue});",
|
|
397
|
+
"insertTextRules": 4,
|
|
398
|
+
"sortText": "02_createContext"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"label": "forwardRef",
|
|
402
|
+
"kind": 1,
|
|
403
|
+
"detail": "React.forwardRef",
|
|
404
|
+
"documentation": { "value": "Creates a React component that forwards the ref attribute to a child component.\n\n```jsx\nconst FancyInput = forwardRef((props, ref) => <input ref={ref} />);\n```" },
|
|
405
|
+
"insertText": "const ${1:Component} = forwardRef<${2:HTMLDivElement}, ${3:Props}>((props, ref) => {\n return <${4:div} ref={ref}>${0}</${4:div}>;\n});",
|
|
406
|
+
"insertTextRules": 4,
|
|
407
|
+
"sortText": "02_forwardRef"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"label": "lazy",
|
|
411
|
+
"kind": 1,
|
|
412
|
+
"detail": "React.lazy",
|
|
413
|
+
"documentation": { "value": "Defines a component that is loaded dynamically via code splitting.\n\n```jsx\nconst OtherComponent = React.lazy(() => import('./OtherComponent'));\n```" },
|
|
414
|
+
"insertText": "const ${1:Component} = lazy(() => import('${2:./path}'));",
|
|
415
|
+
"insertTextRules": 4,
|
|
416
|
+
"sortText": "02_lazy"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"label": "memo",
|
|
420
|
+
"kind": 1,
|
|
421
|
+
"detail": "React.memo",
|
|
422
|
+
"documentation": { "value": "Higher order component that memoizes the result. Only re-renders if props change.\n\n```jsx\nconst MemoComponent = React.memo(MyComponent);\n```" },
|
|
423
|
+
"insertText": "const ${1:MemoizedComponent} = memo(${2:Component}${3:, (prevProps, nextProps) => {\n return ${4:/* true to skip re-render */};\n}});",
|
|
424
|
+
"insertTextRules": 4,
|
|
425
|
+
"sortText": "02_memo"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"label": "startTransition",
|
|
429
|
+
"kind": 1,
|
|
430
|
+
"detail": "React.startTransition",
|
|
431
|
+
"documentation": { "value": "Marks state updates inside the callback as transitions, allowing urgent updates to interrupt them.\n\n```jsx\nstartTransition(() => { setState(newValue); });\n```" },
|
|
432
|
+
"insertText": "startTransition(() => {\n ${1:setState(${2:newValue})};\n});",
|
|
433
|
+
"insertTextRules": 4,
|
|
434
|
+
"sortText": "02_startTransition"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"label": "createPortal",
|
|
438
|
+
"kind": 1,
|
|
439
|
+
"detail": "ReactDOM.createPortal",
|
|
440
|
+
"documentation": { "value": "Creates a portal to render children into a DOM node outside the parent component hierarchy.\n\n```jsx\ncreatePortal(children, domNode, key?)\n```" },
|
|
441
|
+
"insertText": "createPortal(\n ${1:children},\n document.getElementById('${2:portal-root}')!\n)",
|
|
442
|
+
"insertTextRules": 4,
|
|
443
|
+
"sortText": "02_createPortal"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"label": "flushSync",
|
|
447
|
+
"kind": 1,
|
|
448
|
+
"detail": "ReactDOM.flushSync",
|
|
449
|
+
"documentation": { "value": "Forces React to flush any pending state updates synchronously. Use sparingly.\n\n```jsx\nflushSync(() => { setState(newValue); });\n```" },
|
|
450
|
+
"insertText": "flushSync(() => {\n ${1:setState(${2:newValue})};\n});",
|
|
451
|
+
"insertTextRules": 4,
|
|
452
|
+
"sortText": "02_flushSync"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"label": "createRoot",
|
|
456
|
+
"kind": 1,
|
|
457
|
+
"detail": "ReactDOM.createRoot",
|
|
458
|
+
"documentation": { "value": "Creates a root to display React components inside a browser DOM node (React 18+).\n\n```jsx\nconst root = createRoot(document.getElementById('root'));\nroot.render(<App />);\n```" },
|
|
459
|
+
"insertText": "const root = createRoot(document.getElementById('${1:root}')!);\nroot.render(\n <React.StrictMode>\n <${2:App} />\n </React.StrictMode>\n);",
|
|
460
|
+
"insertTextRules": 4,
|
|
461
|
+
"sortText": "02_createRoot"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"label": "hydrateRoot",
|
|
465
|
+
"kind": 1,
|
|
466
|
+
"detail": "ReactDOM.hydrateRoot",
|
|
467
|
+
"documentation": { "value": "Hydrates a server-rendered DOM container with React components.\n\n```jsx\nconst root = hydrateRoot(domNode, reactNode, options?);\n```" },
|
|
468
|
+
"insertText": "const root = hydrateRoot(\n document.getElementById('${1:root}')!,\n <React.StrictMode>\n <${2:App} />\n </React.StrictMode>\n);",
|
|
469
|
+
"insertTextRules": 4,
|
|
470
|
+
"sortText": "02_hydrateRoot"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"label": "Children.map",
|
|
474
|
+
"kind": 1,
|
|
475
|
+
"detail": "React.Children.map",
|
|
476
|
+
"documentation": { "value": "Invokes a function on every immediate child contained within children.\n\n```jsx\nReact.Children.map(children, (child, index) => { ... });\n```" },
|
|
477
|
+
"insertText": "React.Children.map(${1:children}, (child, index) => {\n ${0:return child;}\n})",
|
|
478
|
+
"insertTextRules": 4,
|
|
479
|
+
"sortText": "02_Children_map"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"label": "Children.forEach",
|
|
483
|
+
"kind": 1,
|
|
484
|
+
"detail": "React.Children.forEach",
|
|
485
|
+
"documentation": { "value": "Like React.Children.map() but does not return an array.\n\n```jsx\nReact.Children.forEach(children, (child, index) => { ... });\n```" },
|
|
486
|
+
"insertText": "React.Children.forEach(${1:children}, (child, index) => {\n ${0}\n});",
|
|
487
|
+
"insertTextRules": 4,
|
|
488
|
+
"sortText": "02_Children_forEach"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"label": "Children.count",
|
|
492
|
+
"kind": 1,
|
|
493
|
+
"detail": "React.Children.count",
|
|
494
|
+
"documentation": { "value": "Returns the total number of components in children.\n\n```jsx\nconst count = React.Children.count(children);\n```" },
|
|
495
|
+
"insertText": "React.Children.count(${1:children})",
|
|
496
|
+
"insertTextRules": 4,
|
|
497
|
+
"sortText": "02_Children_count"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"label": "Children.only",
|
|
501
|
+
"kind": 1,
|
|
502
|
+
"detail": "React.Children.only",
|
|
503
|
+
"documentation": { "value": "Verifies that children has only one child and returns it. Throws otherwise.\n\n```jsx\nconst onlyChild = React.Children.only(children);\n```" },
|
|
504
|
+
"insertText": "React.Children.only(${1:children})",
|
|
505
|
+
"insertTextRules": 4,
|
|
506
|
+
"sortText": "02_Children_only"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"label": "Children.toArray",
|
|
510
|
+
"kind": 1,
|
|
511
|
+
"detail": "React.Children.toArray",
|
|
512
|
+
"documentation": { "value": "Returns the children opaque data structure as a flat array with keys assigned.\n\n```jsx\nconst childArray = React.Children.toArray(children);\n```" },
|
|
513
|
+
"insertText": "React.Children.toArray(${1:children})",
|
|
514
|
+
"insertTextRules": 4,
|
|
515
|
+
"sortText": "02_Children_toArray"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"label": "isValidElement",
|
|
519
|
+
"kind": 1,
|
|
520
|
+
"detail": "React.isValidElement",
|
|
521
|
+
"documentation": { "value": "Verifies the object is a React element. Returns true or false.\n\n```jsx\nReact.isValidElement(object);\n```" },
|
|
522
|
+
"insertText": "React.isValidElement(${1:object})",
|
|
523
|
+
"insertTextRules": 4,
|
|
524
|
+
"sortText": "02_isValidElement"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
"label": "cache",
|
|
528
|
+
"kind": 1,
|
|
529
|
+
"detail": "React.cache",
|
|
530
|
+
"documentation": { "value": "Caches the result of a data fetch or computation. React Server Components feature.\n\n```jsx\nconst getData = cache(async (id) => { ... });\n```" },
|
|
531
|
+
"insertText": "const ${1:cachedFn} = cache(async (${2:args}) => {\n ${3:// computation}\n return ${4:result};\n});",
|
|
532
|
+
"insertTextRules": 4,
|
|
533
|
+
"sortText": "02_cache"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"label": "experimental_taintObjectReference",
|
|
537
|
+
"kind": 1,
|
|
538
|
+
"detail": "React.experimental_taintObjectReference",
|
|
539
|
+
"documentation": { "value": "Prevents a specific object from being passed to a Client Component. Server Components security feature.\n\n```jsx\nexperimental_taintObjectReference(message, object);\n```" },
|
|
540
|
+
"insertText": "experimental_taintObjectReference(\n '${1:Do not pass this object to the client}',\n ${2:object}\n);",
|
|
541
|
+
"insertTextRules": 4,
|
|
542
|
+
"sortText": "02_experimental_taintObjectReference"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
"label": "import React",
|
|
546
|
+
"kind": 17,
|
|
547
|
+
"detail": "Import React",
|
|
548
|
+
"documentation": { "value": "Import default React module." },
|
|
549
|
+
"insertText": "import React from 'react';",
|
|
550
|
+
"insertTextRules": 4,
|
|
551
|
+
"sortText": "01_import_react"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
"label": "export default",
|
|
555
|
+
"kind": 17,
|
|
556
|
+
"detail": "Default Export",
|
|
557
|
+
"documentation": { "value": "Export component as default export." },
|
|
558
|
+
"insertText": "export default ${1:ComponentName};",
|
|
559
|
+
"insertTextRules": 4,
|
|
560
|
+
"sortText": "01_export_default"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"label": "Fragment",
|
|
564
|
+
"kind": 17,
|
|
565
|
+
"detail": "React.Fragment",
|
|
566
|
+
"documentation": { "value": "A component that lets you group elements without a wrapper DOM node. Shorthand: `<></>`." },
|
|
567
|
+
"insertText": "Fragment",
|
|
568
|
+
"insertTextRules": 4,
|
|
569
|
+
"sortText": "01_Fragment"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"label": "StrictMode",
|
|
573
|
+
"kind": 17,
|
|
574
|
+
"detail": "React.StrictMode",
|
|
575
|
+
"documentation": { "value": "Activates additional development-only checks and warnings for the component tree." },
|
|
576
|
+
"insertText": "<React.StrictMode>\n ${0}\n</React.StrictMode>",
|
|
577
|
+
"insertTextRules": 4,
|
|
578
|
+
"sortText": "01_StrictMode"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
"label": "Suspense",
|
|
582
|
+
"kind": 17,
|
|
583
|
+
"detail": "React.Suspense",
|
|
584
|
+
"documentation": { "value": "Lets you display a fallback UI while child components are loading (code splitting, data fetching)." },
|
|
585
|
+
"insertText": "<Suspense fallback={<${1:Loading} />}>\n ${0}\n</Suspense>",
|
|
586
|
+
"insertTextRules": 4,
|
|
587
|
+
"sortText": "01_Suspense"
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"label": "Profiler",
|
|
591
|
+
"kind": 17,
|
|
592
|
+
"detail": "React.Profiler",
|
|
593
|
+
"documentation": { "value": "Measures the rendering performance of a React tree programmatically." },
|
|
594
|
+
"insertText": "<Profiler id=\"${1:name}\" onRender={(id, phase, actualDuration) => {\n console.log({ id, phase, actualDuration });\n}}>\n ${0}\n</Profiler>",
|
|
595
|
+
"insertTextRules": 4,
|
|
596
|
+
"sortText": "01_Profiler"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"label": "React.FC",
|
|
600
|
+
"kind": 5,
|
|
601
|
+
"detail": "Type: React.FunctionComponent",
|
|
602
|
+
"documentation": { "value": "Type alias for a functional component. Generic over props type.\n\n```tsx\nconst MyComponent: React.FC<Props> = (props) => { ... };\n```" },
|
|
603
|
+
"insertText": "React.FC<${1:Props}>",
|
|
604
|
+
"insertTextRules": 4,
|
|
605
|
+
"sortText": "03_React_FC"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"label": "React.ReactNode",
|
|
609
|
+
"kind": 5,
|
|
610
|
+
"detail": "Type: React.ReactNode",
|
|
611
|
+
"documentation": { "value": "Represents any renderable React content: elements, strings, numbers, fragments, portals, booleans, null, undefined." },
|
|
612
|
+
"insertText": "React.ReactNode",
|
|
613
|
+
"insertTextRules": 4,
|
|
614
|
+
"sortText": "03_React_ReactNode"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
"label": "React.ReactElement",
|
|
618
|
+
"kind": 5,
|
|
619
|
+
"detail": "Type: React.ReactElement",
|
|
620
|
+
"documentation": { "value": "Represents a React element returned by JSX or createElement. Narrower than ReactNode." },
|
|
621
|
+
"insertText": "React.ReactElement",
|
|
622
|
+
"insertTextRules": 4,
|
|
623
|
+
"sortText": "03_React_ReactElement"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"label": "React.CSSProperties",
|
|
627
|
+
"kind": 5,
|
|
628
|
+
"detail": "Type: React.CSSProperties",
|
|
629
|
+
"documentation": { "value": "Type for inline style objects. All CSS properties converted to camelCase.\n\n```tsx\nconst style: React.CSSProperties = { display: 'flex', gap: '1rem' };\n```" },
|
|
630
|
+
"insertText": "React.CSSProperties",
|
|
631
|
+
"insertTextRules": 4,
|
|
632
|
+
"sortText": "03_React_CSSProperties"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"label": "React.ChangeEvent",
|
|
636
|
+
"kind": 5,
|
|
637
|
+
"detail": "Type: React.ChangeEvent<T>",
|
|
638
|
+
"documentation": { "value": "Event type for onChange handlers on input, select, textarea.\n\n```tsx\nconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { ... };\n```" },
|
|
639
|
+
"insertText": "React.ChangeEvent<${1:HTMLInputElement}>",
|
|
640
|
+
"insertTextRules": 4,
|
|
641
|
+
"sortText": "03_React_ChangeEvent"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"label": "React.FormEvent",
|
|
645
|
+
"kind": 5,
|
|
646
|
+
"detail": "Type: React.FormEvent<T>",
|
|
647
|
+
"documentation": { "value": "Event type for form submission handlers.\n\n```tsx\nconst handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { e.preventDefault(); };\n```" },
|
|
648
|
+
"insertText": "React.FormEvent<${1:HTMLFormElement}>",
|
|
649
|
+
"insertTextRules": 4,
|
|
650
|
+
"sortText": "03_React_FormEvent"
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"label": "React.MouseEvent",
|
|
654
|
+
"kind": 5,
|
|
655
|
+
"detail": "Type: React.MouseEvent<T>",
|
|
656
|
+
"documentation": { "value": "Event type for mouse event handlers (onClick, onMouseEnter, etc.).\n\n```tsx\nconst handleClick = (e: React.MouseEvent<HTMLButtonElement>) => { ... };\n```" },
|
|
657
|
+
"insertText": "React.MouseEvent<${1:HTMLButtonElement}>",
|
|
658
|
+
"insertTextRules": 4,
|
|
659
|
+
"sortText": "03_React_MouseEvent"
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"label": "React.KeyboardEvent",
|
|
663
|
+
"kind": 5,
|
|
664
|
+
"detail": "Type: React.KeyboardEvent<T>",
|
|
665
|
+
"documentation": { "value": "Event type for keyboard event handlers (onKeyDown, onKeyUp, onKeyPress).\n\n```tsx\nconst handleKey = (e: React.KeyboardEvent<HTMLInputElement>) => { ... };\n```" },
|
|
666
|
+
"insertText": "React.KeyboardEvent<${1:HTMLInputElement}>",
|
|
667
|
+
"insertTextRules": 4,
|
|
668
|
+
"sortText": "03_React_KeyboardEvent"
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"label": "React.RefObject",
|
|
672
|
+
"kind": 5,
|
|
673
|
+
"detail": "Type: React.RefObject<T>",
|
|
674
|
+
"documentation": { "value": "Type for refs created with useRef or createRef. The .current property is read-only." },
|
|
675
|
+
"insertText": "React.RefObject<${1:HTMLDivElement}>",
|
|
676
|
+
"insertTextRules": 4,
|
|
677
|
+
"sortText": "03_React_RefObject"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"label": "React.MutableRefObject",
|
|
681
|
+
"kind": 5,
|
|
682
|
+
"detail": "Type: React.MutableRefObject<T>",
|
|
683
|
+
"documentation": { "value": "Type for mutable refs. The .current property can be freely modified." },
|
|
684
|
+
"insertText": "React.MutableRefObject<${1:any}>",
|
|
685
|
+
"insertTextRules": 4,
|
|
686
|
+
"sortText": "03_React_MutableRefObject"
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"label": "React.Dispatch",
|
|
690
|
+
"kind": 5,
|
|
691
|
+
"detail": "Type: React.Dispatch<A>",
|
|
692
|
+
"documentation": { "value": "Type for the dispatch function returned by useReducer.\n\n```tsx\ntype MyDispatch = React.Dispatch<MyAction>;\n```" },
|
|
693
|
+
"insertText": "React.Dispatch<${1:Action}>",
|
|
694
|
+
"insertTextRules": 4,
|
|
695
|
+
"sortText": "03_React_Dispatch"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
"label": "React.SetStateAction",
|
|
699
|
+
"kind": 5,
|
|
700
|
+
"detail": "Type: React.SetStateAction<S>",
|
|
701
|
+
"documentation": { "value": "Type for the argument to a setState function. Can be a value or updater function." },
|
|
702
|
+
"insertText": "React.SetStateAction<${1:StateType}>",
|
|
703
|
+
"insertTextRules": 4,
|
|
704
|
+
"sortText": "03_React_SetStateAction"
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"label": "React.Context",
|
|
708
|
+
"kind": 5,
|
|
709
|
+
"detail": "Type: React.Context<T>",
|
|
710
|
+
"documentation": { "value": "Type for a context object created by createContext." },
|
|
711
|
+
"insertText": "React.Context<${1:ContextType}>",
|
|
712
|
+
"insertTextRules": 4,
|
|
713
|
+
"sortText": "03_React_Context"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
"label": "React.ComponentType",
|
|
717
|
+
"kind": 5,
|
|
718
|
+
"detail": "Type: React.ComponentType<P>",
|
|
719
|
+
"documentation": { "value": "Union type of component class and function component. Useful for HOCs.\n\n```tsx\ntype HOC = (Component: React.ComponentType<Props>) => React.ComponentType<Props>;\n```" },
|
|
720
|
+
"insertText": "React.ComponentType<${1:Props}>",
|
|
721
|
+
"insertTextRules": 4,
|
|
722
|
+
"sortText": "03_React_ComponentType"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"label": "React.PropsWithChildren",
|
|
726
|
+
"kind": 5,
|
|
727
|
+
"detail": "Type: React.PropsWithChildren<P>",
|
|
728
|
+
"documentation": { "value": "Utility type that adds the `children` prop to a props type.\n\n```tsx\ntype MyProps = React.PropsWithChildren<{ title: string }>;\n```" },
|
|
729
|
+
"insertText": "React.PropsWithChildren<${1:Props}>",
|
|
730
|
+
"insertTextRules": 4,
|
|
731
|
+
"sortText": "03_React_PropsWithChildren"
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
"label": "React.HTMLAttributes",
|
|
735
|
+
"kind": 5,
|
|
736
|
+
"detail": "Type: React.HTMLAttributes<T>",
|
|
737
|
+
"documentation": { "value": "Type for all standard HTML attributes for a given element type." },
|
|
738
|
+
"insertText": "React.HTMLAttributes<${1:HTMLDivElement}>",
|
|
739
|
+
"insertTextRules": 4,
|
|
740
|
+
"sortText": "03_React_HTMLAttributes"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
"label": "JSX.Element",
|
|
744
|
+
"kind": 5,
|
|
745
|
+
"detail": "Type: JSX.Element",
|
|
746
|
+
"documentation": { "value": "Represents the return type of a JSX expression. Equivalent to React.ReactElement." },
|
|
747
|
+
"insertText": "JSX.Element",
|
|
748
|
+
"insertTextRules": 4,
|
|
749
|
+
"sortText": "03_JSX_Element"
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
"label": "JSX.IntrinsicElements",
|
|
753
|
+
"kind": 5,
|
|
754
|
+
"detail": "Type: JSX.IntrinsicElements",
|
|
755
|
+
"documentation": { "value": "Interface that maps HTML/SVG tag names to their attribute types. Used for type-checking JSX." },
|
|
756
|
+
"insertText": "JSX.IntrinsicElements",
|
|
757
|
+
"insertTextRules": 4,
|
|
758
|
+
"sortText": "03_JSX_IntrinsicElements"
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"label": "import { useState }",
|
|
762
|
+
"kind": 17,
|
|
763
|
+
"detail": "Import useState hook",
|
|
764
|
+
"documentation": { "value": "Named import of useState from react." },
|
|
765
|
+
"insertText": "import { useState } from 'react';",
|
|
766
|
+
"insertTextRules": 4,
|
|
767
|
+
"sortText": "01_import_useState"
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
"label": "import { useEffect }",
|
|
771
|
+
"kind": 17,
|
|
772
|
+
"detail": "Import useEffect hook",
|
|
773
|
+
"documentation": { "value": "Named import of useEffect from react." },
|
|
774
|
+
"insertText": "import { useEffect } from 'react';",
|
|
775
|
+
"insertTextRules": 4,
|
|
776
|
+
"sortText": "01_import_useEffect"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"label": "import { useContext }",
|
|
780
|
+
"kind": 17,
|
|
781
|
+
"detail": "Import useContext hook",
|
|
782
|
+
"documentation": { "value": "Named import of useContext from react." },
|
|
783
|
+
"insertText": "import { useContext } from 'react';",
|
|
784
|
+
"insertTextRules": 4,
|
|
785
|
+
"sortText": "01_import_useContext"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"label": "import { useReducer }",
|
|
789
|
+
"kind": 17,
|
|
790
|
+
"detail": "Import useReducer hook",
|
|
791
|
+
"documentation": { "value": "Named import of useReducer from react." },
|
|
792
|
+
"insertText": "import { useReducer } from 'react';",
|
|
793
|
+
"insertTextRules": 4,
|
|
794
|
+
"sortText": "01_import_useReducer"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
"label": "import { useMemo }",
|
|
798
|
+
"kind": 17,
|
|
799
|
+
"detail": "Import useMemo hook",
|
|
800
|
+
"documentation": { "value": "Named import of useMemo from react." },
|
|
801
|
+
"insertText": "import { useMemo } from 'react';",
|
|
802
|
+
"insertTextRules": 4,
|
|
803
|
+
"sortText": "01_import_useMemo"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"label": "import { useCallback }",
|
|
807
|
+
"kind": 17,
|
|
808
|
+
"detail": "Import useCallback hook",
|
|
809
|
+
"documentation": { "value": "Named import of useCallback from react." },
|
|
810
|
+
"insertText": "import { useCallback } from 'react';",
|
|
811
|
+
"insertTextRules": 4,
|
|
812
|
+
"sortText": "01_import_useCallback"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
"label": "import { useRef }",
|
|
816
|
+
"kind": 17,
|
|
817
|
+
"detail": "Import useRef hook",
|
|
818
|
+
"documentation": { "value": "Named import of useRef from react." },
|
|
819
|
+
"insertText": "import { useRef } from 'react';",
|
|
820
|
+
"insertTextRules": 4,
|
|
821
|
+
"sortText": "01_import_useRef"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"label": "import ReactDOM",
|
|
825
|
+
"kind": 17,
|
|
826
|
+
"detail": "Import ReactDOM",
|
|
827
|
+
"documentation": { "value": "Import default ReactDOM module for DOM rendering." },
|
|
828
|
+
"insertText": "import ReactDOM from 'react-dom';",
|
|
829
|
+
"insertTextRules": 4,
|
|
830
|
+
"sortText": "01_import_reactdom"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
"label": "import { createRoot }",
|
|
834
|
+
"kind": 17,
|
|
835
|
+
"detail": "Import createRoot from react-dom/client",
|
|
836
|
+
"documentation": { "value": "Named import of createRoot for React 18 rendering." },
|
|
837
|
+
"insertText": "import { createRoot } from 'react-dom/client';",
|
|
838
|
+
"insertTextRules": 4,
|
|
839
|
+
"sortText": "01_import_createRoot"
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
"label": "import { createPortal }",
|
|
843
|
+
"kind": 17,
|
|
844
|
+
"detail": "Import createPortal from react-dom",
|
|
845
|
+
"documentation": { "value": "Named import of createPortal for rendering outside parent hierarchy." },
|
|
846
|
+
"insertText": "import { createPortal } from 'react-dom';",
|
|
847
|
+
"insertTextRules": 4,
|
|
848
|
+
"sortText": "01_import_createPortal"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"label": "import { memo, forwardRef }",
|
|
852
|
+
"kind": 17,
|
|
853
|
+
"detail": "Import memo and forwardRef",
|
|
854
|
+
"documentation": { "value": "Named imports of commonly used React utilities." },
|
|
855
|
+
"insertText": "import { memo, forwardRef } from 'react';",
|
|
856
|
+
"insertTextRules": 4,
|
|
857
|
+
"sortText": "01_import_memo_forwardRef"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
"label": "import { Suspense, lazy }",
|
|
861
|
+
"kind": 17,
|
|
862
|
+
"detail": "Import Suspense and lazy",
|
|
863
|
+
"documentation": { "value": "Named imports for code-splitting support." },
|
|
864
|
+
"insertText": "import { Suspense, lazy } from 'react';",
|
|
865
|
+
"insertTextRules": 4,
|
|
866
|
+
"sortText": "01_import_suspense_lazy"
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
"label": "ruefetch",
|
|
870
|
+
"kind": 28,
|
|
871
|
+
"detail": "useEffect Data Fetching",
|
|
872
|
+
"documentation": { "value": "useEffect pattern for fetching data with loading and error states." },
|
|
873
|
+
"insertText": "const [${1:data}, set${1/(.*)/${1:/capitalize}/}] = useState<${2:DataType} | null>(null);\nconst [loading, setLoading] = useState(true);\nconst [error, setError] = useState<Error | null>(null);\n\nuseEffect(() => {\n let cancelled = false;\n const fetchData = async () => {\n try {\n setLoading(true);\n const response = await fetch('${3:/api/endpoint}');\n if (!response.ok) throw new Error('Failed to fetch');\n const result = await response.json();\n if (!cancelled) {\n set${1/(.*)/${1:/capitalize}/}(result);\n }\n } catch (err) {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n }\n } finally {\n if (!cancelled) setLoading(false);\n }\n };\n fetchData();\n return () => { cancelled = true; };\n}, [${4:}]);",
|
|
874
|
+
"insertTextRules": 4,
|
|
875
|
+
"sortText": "00_ruefetch"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
"label": "ruselocalstorage",
|
|
879
|
+
"kind": 28,
|
|
880
|
+
"detail": "useLocalStorage Custom Hook",
|
|
881
|
+
"documentation": { "value": "Custom hook for syncing state with localStorage." },
|
|
882
|
+
"insertText": "function useLocalStorage<T>(key: string, initialValue: T) {\n const [storedValue, setStoredValue] = useState<T>(() => {\n try {\n const item = window.localStorage.getItem(key);\n return item ? JSON.parse(item) : initialValue;\n } catch {\n return initialValue;\n }\n });\n\n const setValue = (value: T | ((val: T) => T)) => {\n const valueToStore = value instanceof Function ? value(storedValue) : value;\n setStoredValue(valueToStore);\n window.localStorage.setItem(key, JSON.stringify(valueToStore));\n };\n\n return [storedValue, setValue] as const;\n}",
|
|
883
|
+
"insertTextRules": 4,
|
|
884
|
+
"sortText": "00_ruselocalstorage"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"label": "rusemediaquery",
|
|
888
|
+
"kind": 28,
|
|
889
|
+
"detail": "useMediaQuery Custom Hook",
|
|
890
|
+
"documentation": { "value": "Custom hook for responsive design with media queries." },
|
|
891
|
+
"insertText": "function useMediaQuery(query: string): boolean {\n const [matches, setMatches] = useState(() =>\n typeof window !== 'undefined' ? window.matchMedia(query).matches : false\n );\n\n useEffect(() => {\n const mediaQuery = window.matchMedia(query);\n const handler = (e: MediaQueryListEvent) => setMatches(e.matches);\n mediaQuery.addEventListener('change', handler);\n return () => mediaQuery.removeEventListener('change', handler);\n }, [query]);\n\n return matches;\n}",
|
|
892
|
+
"insertTextRules": 4,
|
|
893
|
+
"sortText": "00_rusemediaquery"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"label": "rusedebounce",
|
|
897
|
+
"kind": 28,
|
|
898
|
+
"detail": "useDebounce Custom Hook",
|
|
899
|
+
"documentation": { "value": "Custom hook that debounces a value over a specified delay." },
|
|
900
|
+
"insertText": "function useDebounce<T>(value: T, delay: number): T {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const timer = setTimeout(() => setDebouncedValue(value), delay);\n return () => clearTimeout(timer);\n }, [value, delay]);\n\n return debouncedValue;\n}",
|
|
901
|
+
"insertTextRules": 4,
|
|
902
|
+
"sortText": "00_rusedebounce"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
"label": "ruseprevious",
|
|
906
|
+
"kind": 28,
|
|
907
|
+
"detail": "usePrevious Custom Hook",
|
|
908
|
+
"documentation": { "value": "Custom hook to track the previous value of a state or prop." },
|
|
909
|
+
"insertText": "function usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T>();\n useEffect(() => {\n ref.current = value;\n });\n return ref.current;\n}",
|
|
910
|
+
"insertTextRules": 4,
|
|
911
|
+
"sortText": "00_ruseprevious"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
"label": "rusetoggle",
|
|
915
|
+
"kind": 28,
|
|
916
|
+
"detail": "useToggle Custom Hook",
|
|
917
|
+
"documentation": { "value": "Simple toggle hook for boolean state management." },
|
|
918
|
+
"insertText": "function useToggle(initialValue = false): [boolean, () => void] {\n const [value, setValue] = useState(initialValue);\n const toggle = useCallback(() => setValue(v => !v), []);\n return [value, toggle];\n}",
|
|
919
|
+
"insertTextRules": 4,
|
|
920
|
+
"sortText": "00_rusetoggle"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
"label": "rmodal",
|
|
924
|
+
"kind": 28,
|
|
925
|
+
"detail": "Modal Component",
|
|
926
|
+
"documentation": { "value": "Creates a modal dialog component using portal and keyboard handling." },
|
|
927
|
+
"insertText": "import { createPortal } from 'react-dom';\n\ninterface ${1:Modal}Props {\n isOpen: boolean;\n onClose: () => void;\n children: React.ReactNode;\n title?: string;\n}\n\nexport const ${1:Modal}: React.FC<${1:Modal}Props> = ({ isOpen, onClose, children, title }) => {\n useEffect(() => {\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose();\n };\n if (isOpen) document.addEventListener('keydown', handleEscape);\n return () => document.removeEventListener('keydown', handleEscape);\n }, [isOpen, onClose]);\n\n if (!isOpen) return null;\n\n return createPortal(\n <div className=\"modal-overlay\" onClick={onClose}>\n <div className=\"modal-content\" onClick={(e) => e.stopPropagation()}>\n {title && <h2>{title}</h2>}\n {children}\n <button onClick={onClose}>Close</button>\n </div>\n </div>,\n document.body\n );\n};",
|
|
928
|
+
"insertTextRules": 4,
|
|
929
|
+
"sortText": "00_rmodal"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"label": "rcontext",
|
|
933
|
+
"kind": 28,
|
|
934
|
+
"detail": "Create Context Pattern",
|
|
935
|
+
"documentation": { "value": "Complete context pattern with provider, consumer hook, and type safety." },
|
|
936
|
+
"insertText": "const ${1:MyContext} = createContext<${2:ContextType} | undefined>(undefined);\n\nexport function use${1:MyContext}() {\n const context = useContext(${1:MyContext});\n if (context === undefined) {\n throw new Error('use${1:MyContext} must be used within a ${1:MyContext}Provider');\n }\n return context;\n}\n\nexport function ${1:MyContext}Provider({ children }: { children: React.ReactNode }) {\n const value = ${3:useMemo(() => ({ }), [])};\n return <${1:MyContext}.Provider value={value}>{children}</${1:MyContext}.Provider>;\n}",
|
|
937
|
+
"insertTextRules": 4,
|
|
938
|
+
"sortText": "00_rcontext"
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
"label": "ruseonclickoutside",
|
|
942
|
+
"kind": 28,
|
|
943
|
+
"detail": "useOnClickOutside Custom Hook",
|
|
944
|
+
"documentation": { "value": "Custom hook to detect clicks outside a referenced element." },
|
|
945
|
+
"insertText": "function useOnClickOutside(\n ref: React.RefObject<HTMLElement>,\n handler: (event: MouseEvent | TouchEvent) => void\n) {\n useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n if (!ref.current || ref.current.contains(event.target as Node)) return;\n handler(event);\n };\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, handler]);\n}",
|
|
946
|
+
"insertTextRules": 4,
|
|
947
|
+
"sortText": "00_ruseonclickoutside"
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
"label": "ruseintersectionobserver",
|
|
951
|
+
"kind": 28,
|
|
952
|
+
"detail": "useIntersectionObserver Hook",
|
|
953
|
+
"documentation": { "value": "Custom hook for detecting element visibility in the viewport." },
|
|
954
|
+
"insertText": "function useIntersectionObserver(\n ref: React.RefObject<HTMLElement>,\n options?: IntersectionObserverInit\n): boolean {\n const [isIntersecting, setIntersecting] = useState(false);\n\n useEffect(() => {\n const element = ref.current;\n if (!element) return;\n const observer = new IntersectionObserver(\n ([entry]) => setIntersecting(entry.isIntersecting),\n options\n );\n observer.observe(element);\n return () => observer.disconnect();\n }, [ref, options]);\n\n return isIntersecting;\n}",
|
|
955
|
+
"insertTextRules": 4,
|
|
956
|
+
"sortText": "00_ruseintersectionobserver"
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
"label": "rusekeypress",
|
|
960
|
+
"kind": 28,
|
|
961
|
+
"detail": "useKeyPress Hook",
|
|
962
|
+
"documentation": { "value": "Custom hook to detect when a specific key is pressed." },
|
|
963
|
+
"insertText": "function useKeyPress(targetKey: string): boolean {\n const [keyPressed, setKeyPressed] = useState(false);\n\n useEffect(() => {\n const downHandler = (e: KeyboardEvent) => {\n if (e.key === targetKey) setKeyPressed(true);\n };\n const upHandler = (e: KeyboardEvent) => {\n if (e.key === targetKey) setKeyPressed(false);\n };\n window.addEventListener('keydown', downHandler);\n window.addEventListener('keyup', upHandler);\n return () => {\n window.removeEventListener('keydown', downHandler);\n window.removeEventListener('keyup', upHandler);\n };\n }, [targetKey]);\n\n return keyPressed;\n}",
|
|
964
|
+
"insertTextRules": 4,
|
|
965
|
+
"sortText": "00_rusekeypress"
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
"label": "reventhandler",
|
|
969
|
+
"kind": 28,
|
|
970
|
+
"detail": "Event Handler Pattern",
|
|
971
|
+
"documentation": { "value": "Creates a typed event handler function for React events." },
|
|
972
|
+
"insertText": "const handle${1:Click} = useCallback((e: React.${2:MouseEvent}<${3:HTMLButtonElement}>) => {\n ${4:e.preventDefault();}\n ${0}\n}, []);",
|
|
973
|
+
"insertTextRules": 4,
|
|
974
|
+
"sortText": "00_reventhandler"
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
"label": "rimportall",
|
|
978
|
+
"kind": 28,
|
|
979
|
+
"detail": "Import All Common React Hooks",
|
|
980
|
+
"documentation": { "value": "Import statement for all commonly used React hooks." },
|
|
981
|
+
"insertText": "import {\n useState,\n useEffect,\n useContext,\n useReducer,\n useCallback,\n useMemo,\n useRef\n} from 'react';",
|
|
982
|
+
"insertTextRules": 4,
|
|
983
|
+
"sortText": "00_rimportall"
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"label": "React.SyntheticEvent",
|
|
987
|
+
"kind": 5,
|
|
988
|
+
"detail": "Type: React.SyntheticEvent<T>",
|
|
989
|
+
"documentation": { "value": "Base event type for all React synthetic events. Cross-browser wrapper around native events." },
|
|
990
|
+
"insertText": "React.SyntheticEvent<${1:HTMLElement}>",
|
|
991
|
+
"insertTextRules": 4,
|
|
992
|
+
"sortText": "03_React_SyntheticEvent"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
"label": "React.ComponentProps",
|
|
996
|
+
"kind": 5,
|
|
997
|
+
"detail": "Type: React.ComponentProps<T>",
|
|
998
|
+
"documentation": { "value": "Extracts the props type from a component type. Works with intrinsic elements and custom components.\n\n```tsx\ntype ButtonProps = React.ComponentProps<'button'>;\ntype MyProps = React.ComponentProps<typeof MyComponent>;\n```" },
|
|
999
|
+
"insertText": "React.ComponentProps<${1:typeof Component}>",
|
|
1000
|
+
"insertTextRules": 4,
|
|
1001
|
+
"sortText": "03_React_ComponentProps"
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
"label": "React.ElementType",
|
|
1005
|
+
"kind": 5,
|
|
1006
|
+
"detail": "Type: React.ElementType",
|
|
1007
|
+
"documentation": { "value": "Type representing any valid component type: string (intrinsic element) or component." },
|
|
1008
|
+
"insertText": "React.ElementType",
|
|
1009
|
+
"insertTextRules": 4,
|
|
1010
|
+
"sortText": "03_React_ElementType"
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
"label": "rdynamic",
|
|
1014
|
+
"kind": 28,
|
|
1015
|
+
"detail": "Dynamic Component Rendering",
|
|
1016
|
+
"documentation": { "value": "Pattern for dynamically rendering components based on a map." },
|
|
1017
|
+
"insertText": "const componentMap: Record<string, React.ComponentType<any>> = {\n ${1:type1}: ${2:Component1},\n ${3:type2}: ${4:Component2}\n};\n\nconst DynamicComponent = ({ type, ...props }: { type: string; [key: string]: any }) => {\n const Component = componentMap[type];\n if (!Component) return null;\n return <Component {...props} />;\n};",
|
|
1018
|
+
"insertTextRules": 4,
|
|
1019
|
+
"sortText": "00_rdynamic"
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
"label": "rusewindowsize",
|
|
1023
|
+
"kind": 28,
|
|
1024
|
+
"detail": "useWindowSize Custom Hook",
|
|
1025
|
+
"documentation": { "value": "Custom hook that tracks window dimensions with resize listener." },
|
|
1026
|
+
"insertText": "function useWindowSize() {\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n useEffect(() => {\n const handleResize = () => {\n setSize({ width: window.innerWidth, height: window.innerHeight });\n };\n handleResize();\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n return size;\n}",
|
|
1027
|
+
"insertTextRules": 4,
|
|
1028
|
+
"sortText": "00_rusewindowsize"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
"label": "ruseasync",
|
|
1032
|
+
"kind": 28,
|
|
1033
|
+
"detail": "useAsync Custom Hook",
|
|
1034
|
+
"documentation": { "value": "Generic async operation hook with loading, error, and data states." },
|
|
1035
|
+
"insertText": "function useAsync<T>(asyncFn: () => Promise<T>, deps: any[] = []) {\n const [state, setState] = useState<{\n loading: boolean;\n error: Error | null;\n data: T | null;\n }>({ loading: true, error: null, data: null });\n\n useEffect(() => {\n let cancelled = false;\n setState(s => ({ ...s, loading: true }));\n asyncFn()\n .then(data => { if (!cancelled) setState({ loading: false, error: null, data }); })\n .catch(error => { if (!cancelled) setState({ loading: false, error, data: null }); });\n return () => { cancelled = true; };\n }, deps);\n\n return state;\n}",
|
|
1036
|
+
"insertTextRules": 4,
|
|
1037
|
+
"sortText": "00_ruseasync"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
"label": "rtable",
|
|
1041
|
+
"kind": 28,
|
|
1042
|
+
"detail": "Table Component",
|
|
1043
|
+
"documentation": { "value": "Creates a generic typed table component with column definitions." },
|
|
1044
|
+
"insertText": "interface Column<T> {\n key: keyof T;\n header: string;\n render?: (value: T[keyof T], row: T) => React.ReactNode;\n}\n\ninterface TableProps<T> {\n data: T[];\n columns: Column<T>[];\n}\n\nfunction ${1:Table}<T extends { id: string | number }>({ data, columns }: TableProps<T>) {\n return (\n <table>\n <thead>\n <tr>\n {columns.map(col => (\n <th key={String(col.key)}>{col.header}</th>\n ))}\n </tr>\n </thead>\n <tbody>\n {data.map(row => (\n <tr key={row.id}>\n {columns.map(col => (\n <td key={String(col.key)}>\n {col.render ? col.render(row[col.key], row) : String(row[col.key])}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}",
|
|
1045
|
+
"insertTextRules": 4,
|
|
1046
|
+
"sortText": "00_rtable"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
"label": "rpolymorphic",
|
|
1050
|
+
"kind": 28,
|
|
1051
|
+
"detail": "Polymorphic Component Pattern",
|
|
1052
|
+
"documentation": { "value": "Creates a polymorphic component that can render as different HTML elements." },
|
|
1053
|
+
"insertText": "type ${1:Box}Props<C extends React.ElementType> = {\n as?: C;\n children?: React.ReactNode;\n} & Omit<React.ComponentPropsWithoutRef<C>, 'as' | 'children'>;\n\nexport function ${1:Box}<C extends React.ElementType = 'div'>({\n as,\n children,\n ...props\n}: ${1:Box}Props<C>) {\n const Component = as || 'div';\n return <Component {...props}>{children}</Component>;\n}",
|
|
1054
|
+
"insertTextRules": 4,
|
|
1055
|
+
"sortText": "00_rpolymorphic"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
"label": "rsuspenselist",
|
|
1059
|
+
"kind": 28,
|
|
1060
|
+
"detail": "Suspense List Pattern",
|
|
1061
|
+
"documentation": { "value": "Pattern for coordinating multiple Suspense boundaries." },
|
|
1062
|
+
"insertText": "<Suspense fallback={<${1:Skeleton} />}>\n <${2:DataComponent1} />\n</Suspense>\n<Suspense fallback={<${1:Skeleton} />}>\n <${3:DataComponent2} />\n</Suspense>",
|
|
1063
|
+
"insertTextRules": 4,
|
|
1064
|
+
"sortText": "00_rsuspenselist"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
"label": "rerrboundaryusage",
|
|
1068
|
+
"kind": 28,
|
|
1069
|
+
"detail": "Error Boundary Usage",
|
|
1070
|
+
"documentation": { "value": "Wraps a component tree with an error boundary and fallback UI." },
|
|
1071
|
+
"insertText": "<ErrorBoundary\n fallback={<div>${1:Something went wrong}</div>}\n>\n ${0}\n</ErrorBoundary>",
|
|
1072
|
+
"insertTextRules": 4,
|
|
1073
|
+
"sortText": "00_rerrboundaryusage"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
"label": "roptimisticupdate",
|
|
1077
|
+
"kind": 28,
|
|
1078
|
+
"detail": "Optimistic Update Pattern",
|
|
1079
|
+
"documentation": { "value": "Pattern for optimistic UI updates with rollback on failure." },
|
|
1080
|
+
"insertText": "const [items, setItems] = useState<${1:Item}[]>([]);\n\nconst handleOptimisticUpdate = async (newItem: ${1:Item}) => {\n const previousItems = items;\n setItems(prev => [...prev, newItem]);\n try {\n await ${2:apiCall}(newItem);\n } catch (error) {\n setItems(previousItems);\n ${3:// show error notification}\n }\n};",
|
|
1081
|
+
"insertTextRules": 4,
|
|
1082
|
+
"sortText": "00_roptimisticupdate"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
"label": "import { useId }",
|
|
1086
|
+
"kind": 17,
|
|
1087
|
+
"detail": "Import useId hook",
|
|
1088
|
+
"documentation": { "value": "Named import of useId from react." },
|
|
1089
|
+
"insertText": "import { useId } from 'react';",
|
|
1090
|
+
"insertTextRules": 4,
|
|
1091
|
+
"sortText": "01_import_useId"
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
"label": "import { useTransition }",
|
|
1095
|
+
"kind": 17,
|
|
1096
|
+
"detail": "Import useTransition hook",
|
|
1097
|
+
"documentation": { "value": "Named import of useTransition from react." },
|
|
1098
|
+
"insertText": "import { useTransition } from 'react';",
|
|
1099
|
+
"insertTextRules": 4,
|
|
1100
|
+
"sortText": "01_import_useTransition"
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
"label": "import { useDeferredValue }",
|
|
1104
|
+
"kind": 17,
|
|
1105
|
+
"detail": "Import useDeferredValue hook",
|
|
1106
|
+
"documentation": { "value": "Named import of useDeferredValue from react." },
|
|
1107
|
+
"insertText": "import { useDeferredValue } from 'react';",
|
|
1108
|
+
"insertTextRules": 4,
|
|
1109
|
+
"sortText": "01_import_useDeferredValue"
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
"label": "import { startTransition }",
|
|
1113
|
+
"kind": 17,
|
|
1114
|
+
"detail": "Import startTransition",
|
|
1115
|
+
"documentation": { "value": "Named import of startTransition from react." },
|
|
1116
|
+
"insertText": "import { startTransition } from 'react';",
|
|
1117
|
+
"insertTextRules": 4,
|
|
1118
|
+
"sortText": "01_import_startTransition"
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
"label": "import { createContext, useContext }",
|
|
1122
|
+
"kind": 17,
|
|
1123
|
+
"detail": "Import createContext and useContext",
|
|
1124
|
+
"documentation": { "value": "Named imports for context creation and consumption." },
|
|
1125
|
+
"insertText": "import { createContext, useContext } from 'react';",
|
|
1126
|
+
"insertTextRules": 4,
|
|
1127
|
+
"sortText": "01_import_createContext_useContext"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"label": "import { flushSync }",
|
|
1131
|
+
"kind": 17,
|
|
1132
|
+
"detail": "Import flushSync from react-dom",
|
|
1133
|
+
"documentation": { "value": "Named import of flushSync for synchronous state updates." },
|
|
1134
|
+
"insertText": "import { flushSync } from 'react-dom';",
|
|
1135
|
+
"insertTextRules": 4,
|
|
1136
|
+
"sortText": "01_import_flushSync"
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
"label": "React.DragEvent",
|
|
1140
|
+
"kind": 5,
|
|
1141
|
+
"detail": "Type: React.DragEvent<T>",
|
|
1142
|
+
"documentation": { "value": "Event type for drag and drop handlers." },
|
|
1143
|
+
"insertText": "React.DragEvent<${1:HTMLDivElement}>",
|
|
1144
|
+
"insertTextRules": 4,
|
|
1145
|
+
"sortText": "03_React_DragEvent"
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
"label": "React.FocusEvent",
|
|
1149
|
+
"kind": 5,
|
|
1150
|
+
"detail": "Type: React.FocusEvent<T>",
|
|
1151
|
+
"documentation": { "value": "Event type for focus and blur handlers." },
|
|
1152
|
+
"insertText": "React.FocusEvent<${1:HTMLInputElement}>",
|
|
1153
|
+
"insertTextRules": 4,
|
|
1154
|
+
"sortText": "03_React_FocusEvent"
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
"label": "React.TouchEvent",
|
|
1158
|
+
"kind": 5,
|
|
1159
|
+
"detail": "Type: React.TouchEvent<T>",
|
|
1160
|
+
"documentation": { "value": "Event type for touch event handlers on mobile devices." },
|
|
1161
|
+
"insertText": "React.TouchEvent<${1:HTMLDivElement}>",
|
|
1162
|
+
"insertTextRules": 4,
|
|
1163
|
+
"sortText": "03_React_TouchEvent"
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
"label": "React.ClipboardEvent",
|
|
1167
|
+
"kind": 5,
|
|
1168
|
+
"detail": "Type: React.ClipboardEvent<T>",
|
|
1169
|
+
"documentation": { "value": "Event type for clipboard operations (copy, paste, cut)." },
|
|
1170
|
+
"insertText": "React.ClipboardEvent<${1:HTMLInputElement}>",
|
|
1171
|
+
"insertTextRules": 4,
|
|
1172
|
+
"sortText": "03_React_ClipboardEvent"
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
"label": "React.WheelEvent",
|
|
1176
|
+
"kind": 5,
|
|
1177
|
+
"detail": "Type: React.WheelEvent<T>",
|
|
1178
|
+
"documentation": { "value": "Event type for mouse wheel event handlers." },
|
|
1179
|
+
"insertText": "React.WheelEvent<${1:HTMLDivElement}>",
|
|
1180
|
+
"insertTextRules": 4,
|
|
1181
|
+
"sortText": "03_React_WheelEvent"
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
"label": "React.AnimationEvent",
|
|
1185
|
+
"kind": 5,
|
|
1186
|
+
"detail": "Type: React.AnimationEvent<T>",
|
|
1187
|
+
"documentation": { "value": "Event type for CSS animation event handlers." },
|
|
1188
|
+
"insertText": "React.AnimationEvent<${1:HTMLDivElement}>",
|
|
1189
|
+
"insertTextRules": 4,
|
|
1190
|
+
"sortText": "03_React_AnimationEvent"
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
"label": "React.TransitionEvent",
|
|
1194
|
+
"kind": 5,
|
|
1195
|
+
"detail": "Type: React.TransitionEvent<T>",
|
|
1196
|
+
"documentation": { "value": "Event type for CSS transition event handlers." },
|
|
1197
|
+
"insertText": "React.TransitionEvent<${1:HTMLDivElement}>",
|
|
1198
|
+
"insertTextRules": 4,
|
|
1199
|
+
"sortText": "03_React_TransitionEvent"
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
"label": "React.PointerEvent",
|
|
1203
|
+
"kind": 5,
|
|
1204
|
+
"detail": "Type: React.PointerEvent<T>",
|
|
1205
|
+
"documentation": { "value": "Event type for unified pointer events (mouse, touch, pen)." },
|
|
1206
|
+
"insertText": "React.PointerEvent<${1:HTMLDivElement}>",
|
|
1207
|
+
"insertTextRules": 4,
|
|
1208
|
+
"sortText": "03_React_PointerEvent"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
"label": "React.UIEvent",
|
|
1212
|
+
"kind": 5,
|
|
1213
|
+
"detail": "Type: React.UIEvent<T>",
|
|
1214
|
+
"documentation": { "value": "Base event type for UI events like scroll." },
|
|
1215
|
+
"insertText": "React.UIEvent<${1:HTMLDivElement}>",
|
|
1216
|
+
"insertTextRules": 4,
|
|
1217
|
+
"sortText": "03_React_UIEvent"
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
"label": "rdndinput",
|
|
1221
|
+
"kind": 28,
|
|
1222
|
+
"detail": "Drag and Drop Input",
|
|
1223
|
+
"documentation": { "value": "File drag and drop zone component." },
|
|
1224
|
+
"insertText": "const [isDragOver, setIsDragOver] = useState(false);\n\nconst handleDragOver = (e: React.DragEvent) => {\n e.preventDefault();\n setIsDragOver(true);\n};\n\nconst handleDragLeave = () => setIsDragOver(false);\n\nconst handleDrop = (e: React.DragEvent) => {\n e.preventDefault();\n setIsDragOver(false);\n const files = Array.from(e.dataTransfer.files);\n ${1:// process files}\n};\n\n// <div onDragOver={handleDragOver} onDragLeave={handleDragLeave} onDrop={handleDrop} />",
|
|
1225
|
+
"insertTextRules": 4,
|
|
1226
|
+
"sortText": "00_rdndinput"
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"label": "ruseinterval",
|
|
1230
|
+
"kind": 28,
|
|
1231
|
+
"detail": "useInterval Custom Hook",
|
|
1232
|
+
"documentation": { "value": "Declarative interval hook with automatic cleanup." },
|
|
1233
|
+
"insertText": "function useInterval(callback: () => void, delay: number | null) {\n const savedCallback = useRef(callback);\n\n useEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(() => savedCallback.current(), delay);\n return () => clearInterval(id);\n }, [delay]);\n}",
|
|
1234
|
+
"insertTextRules": 4,
|
|
1235
|
+
"sortText": "00_ruseinterval"
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
"label": "ruseanimationframe",
|
|
1239
|
+
"kind": 28,
|
|
1240
|
+
"detail": "useAnimationFrame Hook",
|
|
1241
|
+
"documentation": { "value": "Hook for running logic on every animation frame." },
|
|
1242
|
+
"insertText": "function useAnimationFrame(callback: (deltaTime: number) => void) {\n const requestRef = useRef<number>();\n const previousTimeRef = useRef<number>();\n\n useEffect(() => {\n const animate = (time: number) => {\n if (previousTimeRef.current !== undefined) {\n const delta = time - previousTimeRef.current;\n callback(delta);\n }\n previousTimeRef.current = time;\n requestRef.current = requestAnimationFrame(animate);\n };\n requestRef.current = requestAnimationFrame(animate);\n return () => {\n if (requestRef.current) cancelAnimationFrame(requestRef.current);\n };\n }, [callback]);\n}",
|
|
1243
|
+
"insertTextRules": 4,
|
|
1244
|
+
"sortText": "00_ruseanimationframe"
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
"label": "rreducerctx",
|
|
1248
|
+
"kind": 28,
|
|
1249
|
+
"detail": "Reducer + Context Pattern",
|
|
1250
|
+
"documentation": { "value": "Combines useReducer with Context for global state management." },
|
|
1251
|
+
"insertText": "type State = { ${1:count}: number };\ntype Action = { type: '${2:INCREMENT}' } | { type: '${3:DECREMENT}' };\n\nconst initialState: State = { ${1:count}: 0 };\n\nfunction reducer(state: State, action: Action): State {\n switch (action.type) {\n case '${2:INCREMENT}': return { ...state, ${1:count}: state.${1:count} + 1 };\n case '${3:DECREMENT}': return { ...state, ${1:count}: state.${1:count} - 1 };\n default: return state;\n }\n}\n\nconst StateContext = createContext<State>(initialState);\nconst DispatchContext = createContext<React.Dispatch<Action>>(() => {});\n\nexport function StateProvider({ children }: { children: React.ReactNode }) {\n const [state, dispatch] = useReducer(reducer, initialState);\n return (\n <StateContext.Provider value={state}>\n <DispatchContext.Provider value={dispatch}>\n {children}\n </DispatchContext.Provider>\n </StateContext.Provider>\n );\n}\n\nexport const useAppState = () => useContext(StateContext);\nexport const useAppDispatch = () => useContext(DispatchContext);",
|
|
1252
|
+
"insertTextRules": 4,
|
|
1253
|
+
"sortText": "00_rreducerctx"
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
"label": "rtest",
|
|
1257
|
+
"kind": 28,
|
|
1258
|
+
"detail": "React Testing Library Test",
|
|
1259
|
+
"documentation": { "value": "Creates a test file structure using React Testing Library." },
|
|
1260
|
+
"insertText": "import { render, screen, fireEvent } from '@testing-library/react';\nimport { ${1:Component} } from './${1:Component}';\n\ndescribe('${1:Component}', () => {\n it('renders correctly', () => {\n render(<${1:Component} ${2:} />);\n expect(screen.getByText('${3:expected text}')).toBeInTheDocument();\n });\n\n it('handles user interaction', () => {\n render(<${1:Component} ${2:} />);\n fireEvent.click(screen.getByRole('button'));\n ${0}\n });\n});",
|
|
1261
|
+
"insertTextRules": 4,
|
|
1262
|
+
"sortText": "00_rtest"
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
"label": "ruseonline",
|
|
1266
|
+
"kind": 28,
|
|
1267
|
+
"detail": "useOnlineStatus Hook",
|
|
1268
|
+
"documentation": { "value": "Hook to track browser online/offline status." },
|
|
1269
|
+
"insertText": "function useOnlineStatus(): boolean {\n const [isOnline, setIsOnline] = useState(navigator.onLine);\n\n useEffect(() => {\n const goOnline = () => setIsOnline(true);\n const goOffline = () => setIsOnline(false);\n window.addEventListener('online', goOnline);\n window.addEventListener('offline', goOffline);\n return () => {\n window.removeEventListener('online', goOnline);\n window.removeEventListener('offline', goOffline);\n };\n }, []);\n\n return isOnline;\n}",
|
|
1270
|
+
"insertTextRules": 4,
|
|
1271
|
+
"sortText": "00_ruseonline"
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
"label": "React.Reducer",
|
|
1275
|
+
"kind": 5,
|
|
1276
|
+
"detail": "Type: React.Reducer<S, A>",
|
|
1277
|
+
"documentation": { "value": "Type for a reducer function used with useReducer." },
|
|
1278
|
+
"insertText": "React.Reducer<${1:State}, ${2:Action}>",
|
|
1279
|
+
"insertTextRules": 4,
|
|
1280
|
+
"sortText": "03_React_Reducer"
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
"label": "React.ReducerAction",
|
|
1284
|
+
"kind": 5,
|
|
1285
|
+
"detail": "Type: React.ReducerAction<R>",
|
|
1286
|
+
"documentation": { "value": "Extracts the action type from a Reducer type." },
|
|
1287
|
+
"insertText": "React.ReducerAction<typeof ${1:reducer}>",
|
|
1288
|
+
"insertTextRules": 4,
|
|
1289
|
+
"sortText": "03_React_ReducerAction"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
"label": "React.ReducerState",
|
|
1293
|
+
"kind": 5,
|
|
1294
|
+
"detail": "Type: React.ReducerState<R>",
|
|
1295
|
+
"documentation": { "value": "Extracts the state type from a Reducer type." },
|
|
1296
|
+
"insertText": "React.ReducerState<typeof ${1:reducer}>",
|
|
1297
|
+
"insertTextRules": 4,
|
|
1298
|
+
"sortText": "03_React_ReducerState"
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
"label": "React.ReactPortal",
|
|
1302
|
+
"kind": 5,
|
|
1303
|
+
"detail": "Type: React.ReactPortal",
|
|
1304
|
+
"documentation": { "value": "Type representing a React portal element." },
|
|
1305
|
+
"insertText": "React.ReactPortal",
|
|
1306
|
+
"insertTextRules": 4,
|
|
1307
|
+
"sortText": "03_React_ReactPortal"
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
"label": "React.ErrorInfo",
|
|
1311
|
+
"kind": 5,
|
|
1312
|
+
"detail": "Type: React.ErrorInfo",
|
|
1313
|
+
"documentation": { "value": "Type for the error info object passed to componentDidCatch. Contains the componentStack." },
|
|
1314
|
+
"insertText": "React.ErrorInfo",
|
|
1315
|
+
"insertTextRules": 4,
|
|
1316
|
+
"sortText": "03_React_ErrorInfo"
|
|
1317
|
+
}
|
|
1318
|
+
]
|
|
1319
|
+
}
|