diff --git a/components/_util/SwitchVersion.js b/components/_util/SwitchVersion.js index d11777061..783cf6d8c 100644 --- a/components/_util/SwitchVersion.js +++ b/components/_util/SwitchVersion.js @@ -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 + 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 }) - return WrapperComponent } export default SwitchVersion diff --git a/docs/demo/form/section-check.jsx b/docs/demo/form/section-check.jsx index 748821b87..6cc7e0a18 100644 --- a/docs/demo/form/section-check.jsx +++ b/docs/demo/form/section-check.jsx @@ -70,7 +70,7 @@ class Demo extends React.Component { count: '' } }) - this.form.resetValidates() + this.form.current.resetValidates() } handleChange(key, e, value, index) {