@umijs/plugins 4.6.48 → 4.6.50

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/dist/layout.js CHANGED
@@ -40,7 +40,7 @@ var import_npmClient = require("./utils/npmClient");
40
40
  var import_resolveProjectDep = require("./utils/resolveProjectDep");
41
41
  var import_withTmpPath = require("./utils/withTmpPath");
42
42
  var antIconsPath = (0, import_plugin_utils.winPath)(
43
- (0, import_path.dirname)(require.resolve("@ant-design/icons/package"))
43
+ (0, import_path.dirname)(require.resolve("@ant-design/icons/package.json"))
44
44
  );
45
45
  var getAllIcons = () => {
46
46
  const iconTypePath = (0, import_path.join)(antIconsPath, "./lib/icons/index.d.ts");
package/libs/model.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  // @ts-ignore
2
2
  import type { models as rawModels } from '@@/plugin-model/model';
3
3
  import isEqual from 'fast-deep-equal';
4
- import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
4
+ import React, { useContext, useEffect, useRef, useState } from 'react';
5
5
 
6
6
  type Models = typeof rawModels;
7
7
 
@@ -35,7 +35,7 @@ class Dispatcher {
35
35
 
36
36
  interface ExecutorProps {
37
37
  hook: () => any;
38
- onUpdate: (val: any) => void;
38
+ onUpdate: (val: any, opts?: { notify: boolean }) => void;
39
39
  namespace: string;
40
40
  }
41
41
 
@@ -55,10 +55,11 @@ function Executor(props: ExecutorProps) {
55
55
  );
56
56
  }
57
57
 
58
- // 首次执行时立刻返回初始值
59
- useMemo(() => {
60
- updateRef.current(data);
61
- }, []);
58
+ // 首次执行时立刻写入初始值,让子组件在首次 render 中能同步取到数据。
59
+ // 订阅通知放在 effect 中,避免 React 19 的 render 阶段跨组件更新警告。
60
+ if (!initialLoad.current) {
61
+ updateRef.current(data, { notify: false });
62
+ }
62
63
 
63
64
  // React 16.13 后 update 函数用 useEffect 包裹
64
65
  useEffect(() => {
@@ -86,9 +87,11 @@ export function Provider(props: {
86
87
  key={namespace}
87
88
  hook={props.models[namespace]}
88
89
  namespace={namespace}
89
- onUpdate={(val) => {
90
+ onUpdate={(val, opts = { notify: true }) => {
90
91
  dispatcher.data[namespace] = val;
91
- dispatcher.update(namespace);
92
+ if (opts.notify) {
93
+ dispatcher.update(namespace);
94
+ }
92
95
  }}
93
96
  />
94
97
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.6.48",
3
+ "version": "4.6.50",
4
4
  "description": "@umijs/plugins",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -45,12 +45,12 @@
45
45
  "styled-components": "6.1.1",
46
46
  "tslib": "^2",
47
47
  "warning": "^4.0.3",
48
- "@umijs/bundler-utils": "4.6.48",
48
+ "@umijs/bundler-utils": "4.6.50",
49
49
  "@umijs/valtio": "1.0.4"
50
50
  },
51
51
  "devDependencies": {
52
52
  "antd": "^4.24.1",
53
- "umi": "4.6.48"
53
+ "umi": "4.6.50"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"