rsuite 4.10.6 → 4.10.7

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.
@@ -164,6 +164,17 @@ function (_React$Component) {
164
164
  }
165
165
  };
166
166
 
167
+ _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
168
+ var preValue = prevProps.value;
169
+ var currentValue = this.props.value;
170
+
171
+ if (preValue !== currentValue) {
172
+ this.setState({
173
+ value: currentValue
174
+ });
175
+ }
176
+ };
177
+
167
178
  _proto.getValue = function getValue() {
168
179
  var value = this.props.value;
169
180
  return _isUndefined(value) ? this.state.value : value;
@@ -189,6 +189,17 @@ function (_React$Component) {
189
189
  }
190
190
  };
191
191
 
192
+ _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
193
+ var preValue = prevProps.value;
194
+ var currentValue = this.props.value;
195
+
196
+ if (preValue !== currentValue) {
197
+ this.setState({
198
+ value: currentValue
199
+ });
200
+ }
201
+ };
202
+
192
203
  _proto.getValue = function getValue() {
193
204
  var value = this.props.value;
194
205
  return (0, _isUndefined2.default)(value) ? this.state.value : value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "4.10.6",
3
+ "version": "4.10.7",
4
4
  "description": "A suite of react components",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -115,6 +115,15 @@ class InputNumber extends React.Component<InputNumberProps, InputNumberState> {
115
115
  this.inputWheelListener.off();
116
116
  }
117
117
  }
118
+ componentDidUpdate(prevProps: InputNumberProps) {
119
+ const { value: preValue } = prevProps;
120
+ const { value: currentValue } = this.props;
121
+ if (preValue !== currentValue) {
122
+ this.setState({
123
+ value: currentValue
124
+ });
125
+ }
126
+ }
118
127
 
119
128
  bindInputRef = ref => {
120
129
  this.input = ref;
@@ -149,4 +149,29 @@ describe('InputNumber', () => {
149
149
  const instance = getDOMNode(<InputNumber classPrefix="custom-prefix" />);
150
150
  assert.ok(instance.className.match(/\bcustom-prefix\b/));
151
151
  });
152
+ it('should be change correct value when reset value', () => {
153
+ let refValue = 0;
154
+ const Wrapper = React.forwardRef((props, ref) => {
155
+ const [value, setValue] = React.useState(refValue);
156
+ const reset = () => {
157
+ setValue(null);
158
+ };
159
+ refValue = value;
160
+ return (
161
+ <div ref={ref}>
162
+ <InputNumber value={value} onChange={setValue} />
163
+ <button id="reset" onClick={reset}>
164
+ reset
165
+ </button>
166
+ </div>
167
+ );
168
+ });
169
+ const instance = getDOMNode(<Wrapper />);
170
+ const resetBtn = instance.querySelector('#reset');
171
+ ReactTestUtils.Simulate.change(instance.querySelector('.rs-input'), { target: { value: 1 } });
172
+ ReactTestUtils.Simulate.click(resetBtn);
173
+ ReactTestUtils.Simulate.change(instance.querySelector('.rs-input'), { target: { value: 1 } });
174
+
175
+ assert.equal(refValue, 1);
176
+ });
152
177
  });