diff --git a/package.json b/package.json index 6d405c31de1..9c5ae211b52 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "@types/node": "^12.6.8", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", + "@types/hoist-non-react-statics": "^3.3.1", "@typescript-eslint/eslint-plugin": "^4.9.1", "@typescript-eslint/parser": "^4.8.2", "@umijs/plugin-sass": "^1.1.1", @@ -160,4 +161,4 @@ "dependencies": { "@ant-design/icons": "^4.0.2" } -} +} \ No newline at end of file diff --git a/packages/react/package.json b/packages/react/package.json index b98e76536b5..a7639ea2a78 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -37,10 +37,11 @@ "dependencies": { "@formily/core": "^2.0.0-beta.3", "@formily/shared": "^2.0.0-beta.3", - "@formily/validator": "^2.0.0-beta.3" + "@formily/validator": "^2.0.0-beta.3", + "hoist-non-react-statics": "^3.3.2" }, "publishConfig": { "access": "public" }, "gitHead": "4d068dad6183e8da294a4c899a158326c0b0b050" -} +} \ No newline at end of file diff --git a/packages/react/src/shared/connect.ts b/packages/react/src/shared/connect.ts index f900e5a8ebe..6388bde9ca8 100644 --- a/packages/react/src/shared/connect.ts +++ b/packages/react/src/shared/connect.ts @@ -4,7 +4,7 @@ import { isVoidField } from '@formily/core' import { observer } from 'mobx-react-lite' import { JSXComponent, IComponentMapper, IStateMapper } from '../types' import { useField } from '../hooks' - +import hoistNonReactStatics from 'hoist-non-react-statics' export function mapProps( ...args: IStateMapper>[] ) { @@ -78,7 +78,7 @@ export function connect>( } ) - if (target['displayName']) Destination.displayName = target['displayName'] + if (target) hoistNonReactStatics(Destination, target) return Destination } diff --git a/yarn.lock b/yarn.lock index 89ea8317cc1..fdca1e938c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3032,6 +3032,14 @@ resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.8.tgz#49348387983075705fe8f4e02fb67f7daaec4934" integrity sha512-S78QIYirQcUoo6UJZx9CSP0O2ix9IaeAXwQi26Rhr/+mg7qqPy8TzaxHSUut7eGjL8WmLccT7/MXf304WjqHcA== +"@types/hoist-non-react-statics@^3.3.1": + version "3.3.1" + resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" + integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA== + dependencies: + "@types/react" "*" + hoist-non-react-statics "^3.3.0" + "@types/http-proxy@^1.17.4": version "1.17.5" resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.5.tgz#c203c5e6e9dc6820d27a40eb1e511c70a220423d" @@ -9352,7 +9360,7 @@ hoist-non-react-statics@^2.1.0: resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47" integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw== -hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.2: +hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==