Skip to content

Commit

Permalink
Merge pull request #1453 from XiaoMi/hotfix/#1408
Browse files Browse the repository at this point in the history
fix: #1408
  • Loading branch information
solarjoker committed Dec 22, 2020
2 parents 5dc439e + 899e835 commit 54ffed3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions components/form/Form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useCallback, useReducer, forwardRef } from 'react'
import React, { useEffect, useCallback, useReducer, forwardRef, useRef } from 'react'
import _ from 'lodash'
import classNames from 'classnames'
import PropTypes from 'prop-types'
Expand Down Expand Up @@ -29,7 +29,8 @@ const InternalForm = (props) => {
onValuesChange,
_type // SchemaForm 内部配置变量
} = props
const [state, dispatch] = useReducer(Immutable.FormReducer, {
const _Immutable = useRef(new Immutable())
const [state, dispatch] = useReducer(_Immutable.current.FormReducer, {
fields: [],
listNames: [],
listValues: {},
Expand All @@ -40,7 +41,7 @@ const InternalForm = (props) => {
// 用户手动设置表单数据
const setFieldsValue = useCallback(
(values) => {
const _fields = Immutable.currentStateFields()
const _fields = _Immutable.current.currentStateFields()
_fields.forEach((item) => {
const { field } = item
// eslint-disable-next-line no-prototype-builtins
Expand Down
3 changes: 1 addition & 2 deletions components/form/FormReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const FILEDS_UPDATE_VALUE = 'FILEDS_UPDATE_VALUE'
export const FILEDS_REMOVE = 'FILEDS_REMOVE'
export const FILEDS_INIT_LIST = 'FILEDS_INIT_LIST'
export const FILEDS_UPDATE_LIST = 'FILEDS_UPDATE_LIST'
class Immutable {
export default class Immutable {
constructor() {
this.state = {}
}
Expand Down Expand Up @@ -48,4 +48,3 @@ class Immutable {
return _.cloneDeep(this.state.fields)
}
}
export default new Immutable()

0 comments on commit 54ffed3

Please sign in to comment.