@modern-js/plugin-garfish 1.21.0 → 1.21.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @modern-js/plugin-garfish
2
2
 
3
+ ## 1.21.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2baa20b: fix: remove useless mount check ref
8
+ 移除过时的确认挂载的 ref
9
+ - @modern-js/runtime@1.21.1
10
+ - @modern-js/utils@1.21.1
11
+
3
12
  ## 1.21.0
4
13
 
5
14
  ### Patch Changes
@@ -11,7 +11,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
11
11
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
12
 
13
13
  // logical reference to https://github.com/jamiebuilds/react-loadable/blob/6201c5837b212d6244c57f3748f2b1375096beeb/src/index.js
14
- import { useState, useRef, useEffect, useCallback } from 'react';
14
+ import { useState, useEffect, useCallback } from 'react';
15
15
  import { logger } from "../util";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -31,7 +31,6 @@ export function Loadable(WrapComponent) {
31
31
  } = props,
32
32
  otherProps = _objectWithoutProperties(props, _excluded);
33
33
 
34
- const mountRef = useRef(false);
35
34
  let delayTimer = null;
36
35
  let timeoutTimer = null;
37
36
  const [state, setState] = useState(() => {
@@ -70,7 +69,6 @@ export function Loadable(WrapComponent) {
70
69
  });
71
70
  const LoadingComponent = (_props$loadable = props.loadable) === null || _props$loadable === void 0 ? void 0 : _props$loadable.loading;
72
71
  useEffect(() => {
73
- mountRef.current = true;
74
72
  logger('Loadable render state', {
75
73
  state,
76
74
  props: otherProps,
@@ -78,7 +76,6 @@ export function Loadable(WrapComponent) {
78
76
  defaultLoadable
79
77
  });
80
78
  return () => {
81
- mountRef.current = false;
82
79
  setStateWithMountCheck({
83
80
  isLoading: false,
84
81
  error: null
@@ -103,10 +100,6 @@ export function Loadable(WrapComponent) {
103
100
  }));
104
101
  }, [state]);
105
102
  const setStateWithMountCheck = useCallback(newState => {
106
- if (!mountRef.current) {
107
- return;
108
- }
109
-
110
103
  setState(state => _objectSpread(_objectSpread({}, state), newState));
111
104
  }, [state]);
112
105
  const showLoading = (state.isLoading || state.error) && LoadingComponent;
@@ -39,7 +39,6 @@ function Loadable(WrapComponent) {
39
39
  } = props,
40
40
  otherProps = _objectWithoutProperties(props, _excluded);
41
41
 
42
- const mountRef = (0, _react.useRef)(false);
43
42
  let delayTimer = null;
44
43
  let timeoutTimer = null;
45
44
  const [state, setState] = (0, _react.useState)(() => {
@@ -78,7 +77,6 @@ function Loadable(WrapComponent) {
78
77
  });
79
78
  const LoadingComponent = (_props$loadable = props.loadable) === null || _props$loadable === void 0 ? void 0 : _props$loadable.loading;
80
79
  (0, _react.useEffect)(() => {
81
- mountRef.current = true;
82
80
  (0, _util.logger)('Loadable render state', {
83
81
  state,
84
82
  props: otherProps,
@@ -86,7 +84,6 @@ function Loadable(WrapComponent) {
86
84
  defaultLoadable
87
85
  });
88
86
  return () => {
89
- mountRef.current = false;
90
87
  setStateWithMountCheck({
91
88
  isLoading: false,
92
89
  error: null
@@ -111,10 +108,6 @@ function Loadable(WrapComponent) {
111
108
  }));
112
109
  }, [state]);
113
110
  const setStateWithMountCheck = (0, _react.useCallback)(newState => {
114
- if (!mountRef.current) {
115
- return;
116
- }
117
-
118
111
  setState(state => _objectSpread(_objectSpread({}, state), newState));
119
112
  }, [state]);
120
113
  const showLoading = (state.isLoading || state.error) && LoadingComponent;
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
4
  var _excluded = ["loadable"];
5
5
  // logical reference to https://github.com/jamiebuilds/react-loadable/blob/6201c5837b212d6244c57f3748f2b1375096beeb/src/index.js
6
- import { useState, useRef, useEffect, useCallback } from 'react';
6
+ import { useState, useEffect, useCallback } from 'react';
7
7
  import { logger } from "../util";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -22,7 +22,6 @@ export function Loadable(WrapComponent) {
22
22
  loadable = _props$loadable === void 0 ? defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE : _props$loadable,
23
23
  otherProps = _objectWithoutProperties(props, _excluded);
24
24
 
25
- var mountRef = useRef(false);
26
25
  var delayTimer = null;
27
26
  var timeoutTimer = null;
28
27
 
@@ -64,7 +63,6 @@ export function Loadable(WrapComponent) {
64
63
 
65
64
  var LoadingComponent = (_props$loadable2 = props.loadable) === null || _props$loadable2 === void 0 ? void 0 : _props$loadable2.loading;
66
65
  useEffect(function () {
67
- mountRef.current = true;
68
66
  logger('Loadable render state', {
69
67
  state: state,
70
68
  props: otherProps,
@@ -72,7 +70,6 @@ export function Loadable(WrapComponent) {
72
70
  defaultLoadable: defaultLoadable
73
71
  });
74
72
  return function () {
75
- mountRef.current = false;
76
73
  setStateWithMountCheck({
77
74
  isLoading: false,
78
75
  error: null
@@ -97,10 +94,6 @@ export function Loadable(WrapComponent) {
97
94
  }));
98
95
  }, [state]);
99
96
  var setStateWithMountCheck = useCallback(function (newState) {
100
- if (!mountRef.current) {
101
- return;
102
- }
103
-
104
97
  setState(function (state) {
105
98
  return _objectSpread(_objectSpread({}, state), newState);
106
99
  });
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.21.0",
14
+ "version": "1.21.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/runtime/index.d.ts",
17
17
  "typesVersions": {
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@babel/runtime": "^7.18.0",
53
- "@modern-js/utils": "1.21.0",
53
+ "@modern-js/utils": "1.21.1",
54
54
  "@types/debug": "^4.1.7",
55
55
  "@types/react-loadable": "^5.5.6",
56
56
  "debug": "^4.3.2",
@@ -59,7 +59,7 @@
59
59
  "react-loadable": "^5.5.0"
60
60
  },
61
61
  "peerDependencies": {
62
- "@modern-js/runtime": "^1.21.0"
62
+ "@modern-js/runtime": "^1.21.1"
63
63
  },
64
64
  "peerDependenciesMeta": {
65
65
  "@modern-js/runtime": {
@@ -67,11 +67,11 @@
67
67
  }
68
68
  },
69
69
  "devDependencies": {
70
- "@modern-js/core": "1.21.0",
71
- "@modern-js/runtime": "1.21.0",
72
- "@modern-js/types": "1.21.0",
73
- "@scripts/build": "1.21.0",
74
- "@scripts/jest-config": "1.21.0",
70
+ "@modern-js/core": "1.21.1",
71
+ "@modern-js/runtime": "1.21.1",
72
+ "@modern-js/types": "1.21.1",
73
+ "@scripts/build": "1.21.1",
74
+ "@scripts/jest-config": "1.21.1",
75
75
  "@testing-library/jest-dom": "^5.16.1",
76
76
  "@testing-library/react": "^12.0.0",
77
77
  "@testing-library/react-hooks": "^7.0.1",