1. import React, {useState} from 'react';
    2. function FunctionComponent(props) {
    3. const [text, setText] = useState('Hello')
    4. const {message} = props
    5. return <div>{text} {message}</div>
    6. }
    1. "use strict";
    2. function _typeof(obj) {
    3. "@babel/helpers - typeof";
    4. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    5. _typeof = function _typeof(obj) {
    6. return typeof obj;
    7. };
    8. } else {
    9. _typeof = function _typeof(obj) {
    10. return obj &&
    11. typeof Symbol === "function" &&
    12. obj.constructor === Symbol &&
    13. obj !== Symbol.prototype
    14. ? "symbol"
    15. : typeof obj;
    16. };
    17. }
    18. return _typeof(obj);
    19. }
    20. require("core-js/modules/es.symbol.js");
    21. require("core-js/modules/es.symbol.description.js");
    22. require("core-js/modules/es.object.to-string.js");
    23. require("core-js/modules/es.symbol.iterator.js");
    24. require("core-js/modules/es.string.iterator.js");
    25. require("core-js/modules/es.array.iterator.js");
    26. require("core-js/modules/web.dom-collections.iterator.js");
    27. require("core-js/modules/es.array.slice.js");
    28. require("core-js/modules/es.function.name.js");
    29. require("core-js/modules/es.array.from.js");
    30. require("core-js/modules/es.weak-map.js");
    31. require("core-js/modules/es.object.define-property.js");
    32. require("core-js/modules/es.object.get-own-property-descriptor.js");
    33. require("core-js/modules/es.array.is-array.js");
    34. var _react = _interopRequireWildcard(require("react"));
    35. function _getRequireWildcardCache() {
    36. if (typeof WeakMap !== "function") return null;
    37. var cache = new WeakMap();
    38. _getRequireWildcardCache = function _getRequireWildcardCache() {
    39. return cache;
    40. };
    41. return cache;
    42. }
    43. function _interopRequireWildcard(obj) {
    44. if (obj && obj.__esModule) {
    45. return obj;
    46. }
    47. if (
    48. obj === null ||
    49. (_typeof(obj) !== "object" && typeof obj !== "function")
    50. ) {
    51. return { default: obj };
    52. }
    53. var cache = _getRequireWildcardCache();
    54. if (cache && cache.has(obj)) {
    55. return cache.get(obj);
    56. }
    57. var newObj = {};
    58. var hasPropertyDescriptor =
    59. Object.defineProperty && Object.getOwnPropertyDescriptor;
    60. for (var key in obj) {
    61. if (Object.prototype.hasOwnProperty.call(obj, key)) {
    62. var desc = hasPropertyDescriptor
    63. ? Object.getOwnPropertyDescriptor(obj, key)
    64. : null;
    65. if (desc && (desc.get || desc.set)) {
    66. Object.defineProperty(newObj, key, desc);
    67. } else {
    68. newObj[key] = obj[key];
    69. }
    70. }
    71. }
    72. newObj["default"] = obj;
    73. if (cache) {
    74. cache.set(obj, newObj);
    75. }
    76. return newObj;
    77. }
    78. function _slicedToArray(arr, i) {
    79. return (
    80. _arrayWithHoles(arr) ||
    81. _iterableToArrayLimit(arr, i) ||
    82. _unsupportedIterableToArray(arr, i) ||
    83. _nonIterableRest()
    84. );
    85. }
    86. function _nonIterableRest() {
    87. throw new TypeError(
    88. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
    89. );
    90. }
    91. function _unsupportedIterableToArray(o, minLen) {
    92. if (!o) return;
    93. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    94. var n = Object.prototype.toString.call(o).slice(8, -1);
    95. if (n === "Object" && o.constructor) n = o.constructor.name;
    96. if (n === "Map" || n === "Set") return Array.from(o);
    97. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
    98. return _arrayLikeToArray(o, minLen);
    99. }
    100. function _arrayLikeToArray(arr, len) {
    101. if (len == null || len > arr.length) len = arr.length;
    102. for (var i = 0, arr2 = new Array(len); i < len; i++) {
    103. arr2[i] = arr[i];
    104. }
    105. return arr2;
    106. }
    107. function _iterableToArrayLimit(arr, i) {
    108. if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr)))
    109. return;
    110. var _arr = [];
    111. var _n = true;
    112. var _d = false;
    113. var _e = undefined;
    114. try {
    115. for (
    116. var _i = arr[Symbol.iterator](), _s;
    117. !(_n = (_s = _i.next()).done);
    118. _n = true
    119. ) {
    120. _arr.push(_s.value);
    121. if (i && _arr.length === i) break;
    122. }
    123. } catch (err) {
    124. _d = true;
    125. _e = err;
    126. } finally {
    127. try {
    128. if (!_n && _i["return"] != null) _i["return"]();
    129. } finally {
    130. if (_d) throw _e;
    131. }
    132. }
    133. return _arr;
    134. }
    135. function _arrayWithHoles(arr) {
    136. if (Array.isArray(arr)) return arr;
    137. }
    138. function FunctionComponent(props) {
    139. var _useState = (0, _react.useState)("Hello"),
    140. _useState2 = _slicedToArray(_useState, 2),
    141. text = _useState2[0],
    142. setText = _useState2[1];
    143. var message = props.message;
    144. return /*#__PURE__*/ _react["default"].createElement(
    145. "div",
    146. null,
    147. text,
    148. " ",
    149. message
    150. );
    151. }
    1. import React, {Component} from 'react';
    2. class ClassComponent extends Component {
    3. state = {
    4. text: 'Hello'
    5. }
    6. render() {
    7. const {message} = this.props
    8. const {text} = this.state
    9. return <div>{text} {message}</div>
    10. }
    11. }
    1. "use strict";
    2. function _typeof(obj) {
    3. "@babel/helpers - typeof";
    4. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    5. _typeof = function _typeof(obj) {
    6. return typeof obj;
    7. };
    8. } else {
    9. _typeof = function _typeof(obj) {
    10. return obj &&
    11. typeof Symbol === "function" &&
    12. obj.constructor === Symbol &&
    13. obj !== Symbol.prototype
    14. ? "symbol"
    15. : typeof obj;
    16. };
    17. }
    18. return _typeof(obj);
    19. }
    20. require("core-js/modules/es.object.set-prototype-of.js");
    21. require("core-js/modules/es.object.get-prototype-of.js");
    22. require("core-js/modules/es.reflect.construct.js");
    23. require("core-js/modules/es.object.create.js");
    24. require("core-js/modules/es.weak-map.js");
    25. require("core-js/modules/es.object.to-string.js");
    26. require("core-js/modules/es.string.iterator.js");
    27. require("core-js/modules/es.array.iterator.js");
    28. require("core-js/modules/web.dom-collections.iterator.js");
    29. require("core-js/modules/es.object.get-own-property-descriptor.js");
    30. require("core-js/modules/es.symbol.js");
    31. require("core-js/modules/es.symbol.description.js");
    32. require("core-js/modules/es.symbol.iterator.js");
    33. require("core-js/modules/es.array.concat.js");
    34. require("core-js/modules/es.object.define-property.js");
    35. var _react = _interopRequireWildcard(require("react"));
    36. function _getRequireWildcardCache() {
    37. if (typeof WeakMap !== "function") return null;
    38. var cache = new WeakMap();
    39. _getRequireWildcardCache = function _getRequireWildcardCache() {
    40. return cache;
    41. };
    42. return cache;
    43. }
    44. function _interopRequireWildcard(obj) {
    45. if (obj && obj.__esModule) {
    46. return obj;
    47. }
    48. if (
    49. obj === null ||
    50. (_typeof(obj) !== "object" && typeof obj !== "function")
    51. ) {
    52. return { default: obj };
    53. }
    54. var cache = _getRequireWildcardCache();
    55. if (cache && cache.has(obj)) {
    56. return cache.get(obj);
    57. }
    58. var newObj = {};
    59. var hasPropertyDescriptor =
    60. Object.defineProperty && Object.getOwnPropertyDescriptor;
    61. for (var key in obj) {
    62. if (Object.prototype.hasOwnProperty.call(obj, key)) {
    63. var desc = hasPropertyDescriptor
    64. ? Object.getOwnPropertyDescriptor(obj, key)
    65. : null;
    66. if (desc && (desc.get || desc.set)) {
    67. Object.defineProperty(newObj, key, desc);
    68. } else {
    69. newObj[key] = obj[key];
    70. }
    71. }
    72. }
    73. newObj["default"] = obj;
    74. if (cache) {
    75. cache.set(obj, newObj);
    76. }
    77. return newObj;
    78. }
    79. function _classCallCheck(instance, Constructor) {
    80. if (!(instance instanceof Constructor)) {
    81. throw new TypeError("Cannot call a class as a function");
    82. }
    83. }
    84. function _defineProperties(target, props) {
    85. for (var i = 0; i < props.length; i++) {
    86. var descriptor = props[i];
    87. descriptor.enumerable = descriptor.enumerable || false;
    88. descriptor.configurable = true;
    89. if ("value" in descriptor) descriptor.writable = true;
    90. Object.defineProperty(target, descriptor.key, descriptor);
    91. }
    92. }
    93. function _createClass(Constructor, protoProps, staticProps) {
    94. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
    95. if (staticProps) _defineProperties(Constructor, staticProps);
    96. return Constructor;
    97. }
    98. function _inherits(subClass, superClass) {
    99. if (typeof superClass !== "function" && superClass !== null) {
    100. throw new TypeError("Super expression must either be null or a function");
    101. }
    102. subClass.prototype = Object.create(superClass && superClass.prototype, {
    103. constructor: { value: subClass, writable: true, configurable: true }
    104. });
    105. if (superClass) _setPrototypeOf(subClass, superClass);
    106. }
    107. function _setPrototypeOf(o, p) {
    108. _setPrototypeOf =
    109. Object.setPrototypeOf ||
    110. function _setPrototypeOf(o, p) {
    111. o.__proto__ = p;
    112. return o;
    113. };
    114. return _setPrototypeOf(o, p);
    115. }
    116. function _createSuper(Derived) {
    117. var hasNativeReflectConstruct = _isNativeReflectConstruct();
    118. return function _createSuperInternal() {
    119. var Super = _getPrototypeOf(Derived),
    120. result;
    121. if (hasNativeReflectConstruct) {
    122. var NewTarget = _getPrototypeOf(this).constructor;
    123. result = Reflect.construct(Super, arguments, NewTarget);
    124. } else {
    125. result = Super.apply(this, arguments);
    126. }
    127. return _possibleConstructorReturn(this, result);
    128. };
    129. }
    130. function _possibleConstructorReturn(self, call) {
    131. if (call && (_typeof(call) === "object" || typeof call === "function")) {
    132. return call;
    133. }
    134. return _assertThisInitialized(self);
    135. }
    136. function _assertThisInitialized(self) {
    137. if (self === void 0) {
    138. throw new ReferenceError(
    139. "this hasn't been initialised - super() hasn't been called"
    140. );
    141. }
    142. return self;
    143. }
    144. function _isNativeReflectConstruct() {
    145. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
    146. if (Reflect.construct.sham) return false;
    147. if (typeof Proxy === "function") return true;
    148. try {
    149. Boolean.prototype.valueOf.call(
    150. Reflect.construct(Boolean, [], function () {})
    151. );
    152. return true;
    153. } catch (e) {
    154. return false;
    155. }
    156. }
    157. function _getPrototypeOf(o) {
    158. _getPrototypeOf = Object.setPrototypeOf
    159. ? Object.getPrototypeOf
    160. : function _getPrototypeOf(o) {
    161. return o.__proto__ || Object.getPrototypeOf(o);
    162. };
    163. return _getPrototypeOf(o);
    164. }
    165. function _defineProperty(obj, key, value) {
    166. if (key in obj) {
    167. Object.defineProperty(obj, key, {
    168. value: value,
    169. enumerable: true,
    170. configurable: true,
    171. writable: true
    172. });
    173. } else {
    174. obj[key] = value;
    175. }
    176. return obj;
    177. }
    178. var ClassComponent = /*#__PURE__*/ (function (_Component) {
    179. _inherits(ClassComponent, _Component);
    180. var _super = _createSuper(ClassComponent);
    181. function ClassComponent() {
    182. var _this;
    183. _classCallCheck(this, ClassComponent);
    184. for (
    185. var _len = arguments.length, args = new Array(_len), _key = 0;
    186. _key < _len;
    187. _key++
    188. ) {
    189. args[_key] = arguments[_key];
    190. }
    191. _this = _super.call.apply(_super, [this].concat(args));
    192. _defineProperty(_assertThisInitialized(_this), "state", {
    193. text: "Hello"
    194. });
    195. return _this;
    196. }
    197. _createClass(ClassComponent, [
    198. {
    199. key: "render",
    200. value: function render() {
    201. var message = this.props.message;
    202. var text = this.state.text;
    203. return /*#__PURE__*/ _react["default"].createElement(
    204. "div",
    205. null,
    206. text,
    207. " ",
    208. message
    209. );
    210. }
    211. }
    212. ]);
    213. return ClassComponent;
    214. })(_react.Component);