Guest User

Untitled

a guest
Jun 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. {
  2. /*
  3. // Place your snippets for JavaScript React here. Each snippet is defined under a snippet name and has a prefix, body and
  4. // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
  5. // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
  6. // same ids are connected.
  7. // Example:
  8. "Print to console": {
  9. "prefix": "log",
  10. "body": [
  11. "console.log('$1');",
  12. "$2"
  13. ],
  14. "description": "Log output to console"
  15. }
  16. */
  17. "Import react": {
  18. "prefix": "react",
  19. "body": [
  20. "import React from 'react';",
  21. "import PropTypes from 'prop-types';\n\n"
  22. ]
  23. },
  24. "Import CSS component styles": {
  25. "prefix": "styles",
  26. "body": "import styles from './${TM_FILENAME_BASE}.scss';\n\n"
  27. },
  28. "Create component": {
  29. "prefix": "comp",
  30. "body": [
  31. "class ${1:NewComponent} extends React.Component {",
  32. "\tstatic propTypes = {",
  33. "\t\t",
  34. "\t}",
  35. "",
  36. "\tconstructor(props) {",
  37. "\t\tsuper(props);",
  38. "\t\tthis.state = {",
  39. "\t\t\t",
  40. "\t\t};",
  41. "\t}",
  42. "",
  43. "\trender() {",
  44. "\t\treturn (",
  45. "\t\t\t<div>",
  46. "\t\t\t\t${0}",
  47. "\t\t\t</div>",
  48. "\t\t);",
  49. "\t}",
  50. "}",
  51. "",
  52. ],
  53. "description": "Creates react class component"
  54. },
  55. "Create pure component": {
  56. "prefix": "pcomp",
  57. "body": [
  58. "class ${1:NewComponent} extends React.PureComponent {",
  59. "\tconstructor(props) {",
  60. "\t\tsuper(props);",
  61. "\t\tthis.state = {",
  62. "\t\t\t${4}",
  63. "\t\t};",
  64. "\t}",
  65. "",
  66. "\trender() {",
  67. "\t\treturn (",
  68. "\t\t\t<div>",
  69. "\t\t\t\t${0}",
  70. "\t\t\t</div>",
  71. "\t\t);",
  72. "\t}",
  73. "}",
  74. "",
  75. "${1}.propTypes = {",
  76. "\t${2}",
  77. "};",
  78. "",
  79. "${1}.defaultProps = {",
  80. "\t${3}",
  81. "};\n",
  82. ],
  83. "description": "Create pure component"
  84. },
  85. "Create functional component": {
  86. "prefix": "fcomp",
  87. "body": [
  88. "const ${1:NewComponent} = ({${2}}) => {",
  89. "\treturn (",
  90. "\t\t<div>",
  91. "\t\t\t${0}",
  92. "\t\t</div>",
  93. "\t);",
  94. "};",
  95. "",
  96. "${1}.propTypes = {",
  97. "\t${3}",
  98. "};",
  99. "",
  100. "${1}.defaultProps = {",
  101. "\t${4}",
  102. "};\n",
  103. ],
  104. "description": "Create functional component"
  105. },
  106. "Create HOC": {
  107. "prefix": "hoc",
  108. "body": [
  109. "export function ${1:withHOC}(WrappedComponent) {",
  110. "\treturn class extends React.Component {",
  111. "\t\trender() {",
  112. "\t\t\treturn <WrappedComponent {...this.props} />",
  113. "\t\t}",
  114. "\t}",
  115. "}",
  116. ]
  117. }
  118. }
Add Comment
Please, Sign In to add comment