From 2038dbacb9fc98e4885777384abe10ee6b17f7da Mon Sep 17 00:00:00 2001
From: Bougie <1742070326@qq.com>
Date: Tue, 8 Oct 2019 20:00:23 +0800
Subject: [PATCH] fix: switchversion (#708)
---
components/_util/SwitchVersion.js | 16 +++++++++-------
docs/demo/form/section-check.jsx | 2 +-
2 files changed, 10 insertions(+), 8 deletions(-)
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) {