Skip to content

Commit

Permalink
Merge pull request #711 from XiaoMi/hotfix/#708
Browse files Browse the repository at this point in the history
fix: switchversion (#708)
  • Loading branch information
solarjoker authored Oct 9, 2019
2 parents e52b023 + 2038dba commit a05f655
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions components/_util/SwitchVersion.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React, { forwardRef } from 'react'

function SwitchVersion (component = {}, componentLegacy = {}) {
const WrapperComponent = forwardRef(({ legacy, ...props }, ref) => {
const InnerComponent = legacy === true ? componentLegacy : component
for (const staticProp in InnerComponent) {
WrapperComponent[staticProp] = InnerComponent[staticProp]
}
return <InnerComponent {...{ ...props, ref }} />
const WrapperComponent = ({ legacy, innerRef, ...props }) => {
const innerComponent = legacy === true ? componentLegacy : component
return React.createElement(
innerComponent,
Object.assign({}, props, { ref: innerRef })
)
}
return forwardRef((props, ref) => {
return <WrapperComponent {...props} ref={ref} />
})
return WrapperComponent
}

export default SwitchVersion
2 changes: 1 addition & 1 deletion docs/demo/form/section-check.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Demo extends React.Component {
count: ''
}
})
this.form.resetValidates()
this.form.current.resetValidates()
}
handleChange(key, e, value, index) {
Expand Down

0 comments on commit a05f655

Please sign in to comment.