react-hook-form 7.19.4 → 7.19.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -116,23 +116,29 @@ const tearDown = (_subscription) => {
116
116
  _subscription.current = undefined;
117
117
  }
118
118
  };
119
- const updateSubscriptionProps = ({ _subscription, props }) => {
120
- if (props.disabled) {
119
+ const updateSubscriptionProps = ({ _subscription, _props }) => {
120
+ if (_props.current.disabled) {
121
121
  tearDown(_subscription);
122
122
  }
123
123
  else if (!_subscription.current) {
124
- _subscription.current = props.subject.subscribe({
125
- next: props.callback,
124
+ _subscription.current = _props.current.subject.subscribe({
125
+ next: _props.current.callback,
126
126
  });
127
127
  }
128
128
  };
129
129
  function useSubscribe(props) {
130
130
  const _subscription = React.useRef();
131
+ const _props = React.useRef(props);
132
+ _props.current = props;
131
133
  updateSubscriptionProps({
132
134
  _subscription,
133
- props,
135
+ _props,
134
136
  });
135
137
  React.useEffect(() => {
138
+ updateSubscriptionProps({
139
+ _subscription,
140
+ _props,
141
+ });
136
142
  return () => tearDown(_subscription);
137
143
  }, []);
138
144
  }