Skip to content

Commit

Permalink
feat(react): connect add hoistNonReactStatics
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Jan 30, 2021
1 parent 150285b commit 9b68f1e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -160,4 +161,4 @@
"dependencies": {
"@ant-design/icons": "^4.0.2"
}
}
}
5 changes: 3 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions packages/react/src/shared/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends JSXComponent>(
...args: IStateMapper<React.ComponentProps<T>>[]
) {
Expand Down Expand Up @@ -78,7 +78,7 @@ export function connect<T extends React.JSXElementConstructor<any>>(
}
)

if (target['displayName']) Destination.displayName = target['displayName']
if (target) hoistNonReactStatics(Destination, target)

return Destination
}
Expand Down
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit 9b68f1e

Please sign in to comment.