typescriptreact.snippets 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # React
  2. # - - - - - - - - - - - - - - - - - -
  3. snippet fc "Functional Component" b
  4. import React from "react";
  5. const $1: React.FC = () => {
  6. return (
  7. $2
  8. )
  9. }
  10. export default $1;
  11. endsnippet
  12. snippet ue "use effect" b
  13. useEffect(() => {
  14. $1
  15. }, []);
  16. endsnippet
  17. snippet us "use state" b
  18. const [$1, $2] = useState();
  19. endsnippet
  20. snippet um "use memo" b
  21. const $1 = useMemo(() => {
  22. $2
  23. }, [$3]);
  24. endsnippet
  25. snippet ul "use loading state" b
  26. const [loading, setLoading] = useLoading();
  27. endsnippet
  28. snippet dis "eslint disable next line exhaustive deps" b
  29. // eslint-disable-next-line react-hooks/exhaustive-deps
  30. endsnippet
  31. snippet input "Form Input"
  32. <Input
  33. name="$1"
  34. register={register}
  35. error={errors.$1?.message}
  36. />
  37. endsnippet
  38. snippet cn "class name property"
  39. className="$1"
  40. endsnippet
  41. snippet d "class name property" b
  42. <div className="$1">
  43. $2
  44. </div>
  45. endsnippet
  46. snippet cl "console.log" b
  47. console.log('$1: ', $1);
  48. endsnippet
  49. # Node
  50. # - - - - - - - - - - - - - - - - - -
  51. snippet ce "console.error" b
  52. if (process.env.NODE_ENV !== 'production') console.error(error)
  53. endsnippet
  54. # TailwindCSS
  55. # - - - - - - - - - - - - - - - - - -
  56. snippet tp "text-primary"
  57. text-primary-light dark:text-primary-dark
  58. endsnippet
  59. snippet tg1 "text-gray-100"
  60. text-gray-100 dark:text-gray-900
  61. endsnippet
  62. snippet tg2 "text-gray-200"
  63. text-gray-200 dark:text-gray-800
  64. endsnippet
  65. snippet tg3 "text-gray-300"
  66. text-gray-300 dark:text-gray-700
  67. endsnippet
  68. snippet tg4 "text-gray-400"
  69. text-gray-400 dark:text-gray-600
  70. endsnippet
  71. snippet tg5 "text-gray-500"
  72. text-gray-500
  73. endsnippet
  74. snippet tg6 "text-gray-600"
  75. text-gray-600 dark:text-gray-400
  76. endsnippet
  77. snippet tg7 "text-gray-700"
  78. text-gray-700 dark:text-gray-300
  79. endsnippet
  80. snippet tg8 "text-gray-800"
  81. text-gray-800 dark:text-gray-200
  82. endsnippet
  83. snippet tg9 "text-gray-900"
  84. text-gray-900 dark:text-gray-100
  85. endsnippet
  86. snippet tw "text-white"
  87. text-white dark:text-black
  88. endsnippet
  89. snippet tw "text-white"
  90. text-white dark:text-black
  91. endsnippet
  92. # NextJS
  93. # - - - - - - - - - - - - - - - - - -
  94. snippet np "NextJS Page" b
  95. import { NextPage } from "next";
  96. const $1: NextPage = () => {
  97. return (
  98. $2
  99. );
  100. };
  101. export default $1;
  102. endsnippet
  103. snippet ed "export default" b
  104. export default $1
  105. endsnippet
  106. # Remix
  107. # - - - - - - - - - - - - - - - - - -
  108. snippet loader "remix loader" b
  109. export const loader = async ({ params }: LoaderArgs) => {
  110. return {}
  111. }
  112. endsnippet
  113. # Other
  114. # - - - - - - - - - - - - - - - - - -
  115. snippet inv "invariant" b
  116. invariant($1, 'expected $1')
  117. endsnippet