diff --git a/lib/Field.js b/lib/Field.js index 23e04e3..185d496 100644 --- a/lib/Field.js +++ b/lib/Field.js @@ -128,13 +128,15 @@ var Field = (_temp = _class = function (_Component) { }, { key: 'componentDidUpdate', value: function componentDidUpdate(prevProps) { - if (this.$formContext.$$register && prevProps.name !== this.$name) { - this.$name = this.props.name; - - if (this.$name) { - this.$formContext.$$register(this.$name, this.$handler, prevProps.name); - } else { - this.$formContext.$$unregister(prevProps.$name, this.$handler); + if (this.props.name !== prevProps.name) { + this.$name = this.$handler.$name = this.props.name; + + if (this.$formContext.$$register) { + if (this.$name) { + this.$formContext.$$register(this.$name, this.$handler, prevProps.name); + } else { + this.$formContext.$$unregister(prevProps.$name, this.$handler); + } } } } diff --git a/src/Field.js b/src/Field.js index 1f12bef..2d2aa05 100644 --- a/src/Field.js +++ b/src/Field.js @@ -126,13 +126,15 @@ class Field extends Component { } componentDidUpdate(prevProps) { - if (this.$formContext.$$register && prevProps.name !== this.$name) { - this.$name = this.props.name; - - if (this.$name) { - this.$formContext.$$register(this.$name, this.$handler, prevProps.name); - } else { - this.$formContext.$$unregister(prevProps.$name, this.$handler); + if (this.props.name !== prevProps.name) { + this.$name = this.$handler.$name = this.props.name; + + if (this.$formContext.$$register) { + if (this.$name) { + this.$formContext.$$register(this.$name, this.$handler, prevProps.name); + } else { + this.$formContext.$$unregister(prevProps.$name, this.$handler); + } } } }